View | Details | Raw Unified | Return to bug 53268
Collapse All | Expand All

(-)sources/org/apache/batik/transcoder/wmf/tosvg/AbstractWMFPainter.java (-1 / +31 lines)
Lines 140-146 Link Here
140
            // Determine the number of colors
140
            // Determine the number of colors
141
            int nbColors = 0;
141
            int nbColors = 0;
142
            if (_clrused > 0) nbColors = _clrused;
142
            if (_clrused > 0) nbColors = _clrused;
143
            else nbColors = (1 & 0x00ff) << 8;
143
            else nbColors = 1 << 8;
144
            // Read the palette colors.
144
            // Read the palette colors.
145
            int offset = _headerSize;
145
            int offset = _headerSize;
146
            int[]  palette = new int[nbColors];
146
            int[]  palette = new int[nbColors];
Lines 164-169 Link Here
164
                }
164
                }
165
                offset += pad;
165
                offset += pad;
166
            }
166
            }
167
        // 4 bit image
168
        } else if (_nbit == 4) {
169
            // Determine the number of colors
170
            int nbColors = 0;
171
            if (_clrused > 0) nbColors = _clrused;
172
            else nbColors = 1 << 4;
173
            // Read the palette colors.
174
            int offset = _headerSize;
175
            int[] palette = new int[nbColors];
176
            for (int i = 0; i < nbColors; i++) {
177
                palette[i] = (255 & 0x00ff) << 24 | (((int)bit[offset+2] & 0x00ff) << 16)
178
                            | (((int)bit[offset+1] & 0x00ff) << 8)
179
                            | (int)bit[offset] & 0x00ff;
180
                offset += 4;
181
            }
182
183
            // populate the int array
184
            int usedBytesPerRow = _width / 2;
185
            if (_width % 2 != 0) usedBytesPerRow++;
186
            int pad = (_size / _height) - usedBytesPerRow;
187
            for (int j = 0; j < _height; j++) {
188
                for (int i = 0; i < _width; i+=2) {
189
                    int nibble1 = (int) ((bit[offset] >> 4) & 0x000f);
190
                    int nibble2 = (int) (bit[offset] & 0x000f);
191
                    bitI[_width*(_height-j-1)+i] = palette [nibble1];
192
                    bitI[_width*(_height-j-1)+i+1] = palette [nibble2];
193
                    offset++;
194
                }
195
                offset += pad;
196
            }
167
        // black and white image
197
        // black and white image
168
        } else if (_nbit == 1) {
198
        } else if (_nbit == 1) {
169
            // 2 colors only (black and white image)
199
            // 2 colors only (black and white image)

Return to bug 53268