Mercurial > projects > dwt-mac
comparison dwt/internal/image/PngIendChunk.d @ 34:5123b17c98ef
Ported dwt.events.*, dwt.graphics.GC, Region, dwt.internal.image.*
author | Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com> |
---|---|
date | Sun, 14 Sep 2008 01:45:57 +0200 |
parents | 1a8b3cb347e0 |
children |
comparison
equal
deleted
inserted
replaced
33:965ac0a77267 | 34:5123b17c98ef |
---|---|
5 * which accompanies this distribution, and is available at | 5 * which accompanies this distribution, and is available at |
6 * http://www.eclipse.org/legal/epl-v10.html | 6 * http://www.eclipse.org/legal/epl-v10.html |
7 * | 7 * |
8 * Contributors: | 8 * Contributors: |
9 * IBM Corporation - initial API and implementation | 9 * IBM Corporation - initial API and implementation |
10 * Port to the D programming language: | |
11 * Frank Benoit <benoit@tionex.de> | |
10 *******************************************************************************/ | 12 *******************************************************************************/ |
11 module dwt.internal.image; | 13 module dwt.internal.image.PngIendChunk; |
12 | 14 |
13 | 15 |
14 import dwt.DWT; | 16 import dwt.DWT; |
17 import dwt.internal.image.PngFileReadState; | |
18 import dwt.internal.image.PngIhdrChunk; | |
19 import dwt.internal.image.PngChunk; | |
15 | 20 |
16 class PngIendChunk : PngChunk { | 21 class PngIendChunk : PngChunk { |
17 | 22 |
18 this() { | 23 this() { |
19 super(0); | 24 super(0); |
23 | 28 |
24 this(byte[] reference){ | 29 this(byte[] reference){ |
25 super(reference); | 30 super(reference); |
26 } | 31 } |
27 | 32 |
28 int getChunkType() { | 33 override int getChunkType() { |
29 return CHUNK_IEND; | 34 return CHUNK_IEND; |
30 } | 35 } |
31 | 36 |
32 /** | 37 /** |
33 * Answer whether the chunk is a valid IEND chunk. | 38 * Answer whether the chunk is a valid IEND chunk. |
34 */ | 39 */ |
35 void validate(PngFileReadState readState, PngIhdrChunk headerChunk) { | 40 override void validate(PngFileReadState readState, PngIhdrChunk headerChunk) { |
36 // An IEND chunk is invalid if no IHDR has been read. | 41 // An IEND chunk is invalid if no IHDR has been read. |
37 // Or if a palette is required and has not been read. | 42 // Or if a palette is required and has not been read. |
38 // Or if no IDAT chunk has been read. | 43 // Or if no IDAT chunk has been read. |
39 if (!readState.readIHDR | 44 if (!readState.readIHDR |
40 || (headerChunk.getMustHavePalette() && !readState.readPLTE) | 45 || (headerChunk.getMustHavePalette() && !readState.readPLTE) |
41 || !readState.readIDAT | 46 || !readState.readIDAT |
42 || readState.readIEND) | 47 || readState.readIEND) |
43 { | 48 { |
44 DWT.error(DWT.ERROR_INVALID_IMAGE); | 49 DWT.error(DWT.ERROR_INVALID_IMAGE); |
45 } else { | 50 } else { |
46 readState.readIEND = true; | 51 readState.readIEND = true; |
47 } | 52 } |
48 | 53 |
49 super.validate(readState, headerChunk); | 54 super.validate(readState, headerChunk); |
50 | 55 |
51 // IEND chunks are not allowed to have any data. | 56 // IEND chunks are not allowed to have any data. |
52 if (getLength() > 0) DWT.error(DWT.ERROR_INVALID_IMAGE); | 57 if (getLength() > 0) DWT.error(DWT.ERROR_INVALID_IMAGE); |
53 } | 58 } |
54 | 59 |
55 } | 60 } |