comparison dwt/internal/image/PngPlteChunk.d @ 213:36f5cb12e1a2

Update to SWT 3.4M7
author Frank Benoit <benoit@tionex.de>
date Sat, 17 May 2008 17:34:28 +0200
parents ab60f3309436
children 0e2b4fed7a0f
comparison
equal deleted inserted replaced
212:ab60f3309436 213:36f5cb12e1a2
10 * Port to the D programming language: 10 * Port to the D programming language:
11 * Frank Benoit <benoit@tionex.de> 11 * Frank Benoit <benoit@tionex.de>
12 *******************************************************************************/ 12 *******************************************************************************/
13 module dwt.internal.image.PngPlteChunk; 13 module dwt.internal.image.PngPlteChunk;
14 14
15 import dwt.dwthelper.utils;
16
15 17
16 import dwt.DWT; 18 import dwt.DWT;
17 import dwt.graphics.PaletteData; 19 import dwt.graphics.PaletteData;
18 import dwt.graphics.RGB; 20 import dwt.graphics.RGB;
19 import dwt.internal.image.PngChunk; 21 import dwt.internal.image.PngChunk;
20 import dwt.internal.image.PngFileReadState; 22 import dwt.internal.image.PngFileReadState;
21 import dwt.internal.image.PngIhdrChunk; 23 import dwt.internal.image.PngIhdrChunk;
22 24
23 import tango.text.convert.Format; 25 import tango.text.convert.Format;
24 import dwt.dwthelper.utils;
25 26
26 class PngPlteChunk : PngChunk { 27 class PngPlteChunk : PngChunk {
27 28
28 int paletteSize; 29 int paletteSize;
29 30
109 // Note: just ignore the palette. 110 // Note: just ignore the palette.
110 // if (!headerChunk.getCanHavePalette()) DWT.error(DWT.ERROR_INVALID_IMAGE); 111 // if (!headerChunk.getCanHavePalette()) DWT.error(DWT.ERROR_INVALID_IMAGE);
111 112
112 // Palette chunks' data fields must be event multiples 113 // Palette chunks' data fields must be event multiples
113 // of 3. Each 3-byte group represents an RGB value. 114 // of 3. Each 3-byte group represents an RGB value.
114 if (getLength() % 3 !is 0) DWT.error(DWT.ERROR_INVALID_IMAGE); 115 if (getLength() % 3 !is 0) DWT.error(DWT.ERROR_INVALID_IMAGE);
115 116
116 // Palettes cannot have more entries than 2^bitDepth 117 // Palettes cannot have more entries than 2^bitDepth
117 // where bitDepth is the bit depth of the image given 118 // where bitDepth is the bit depth of the image given
118 // in the IHDR chunk. 119 // in the IHDR chunk.
119 if (1 << headerChunk.getBitDepth() < paletteSize) { 120 if (1 << headerChunk.getBitDepth() < paletteSize) {