root/dwt/internal/image/PngIendChunk.d

Revision 48:9a64a7781bab, 1.7 kB (checked in by Frank Benoit <benoit@tionex.de>, 1 year ago)

Added override and alias, first chunk. Thanks torhu for doing this patch.

Line 
1 /*******************************************************************************
2  * Copyright (c) 2000, 2006 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  *     IBM Corporation - initial API and implementation
10  * Port to the D programming language:
11  *     Frank Benoit <benoit@tionex.de>
12  *******************************************************************************/
13 module dwt.internal.image.PngIendChunk;
14
15
16 import dwt.DWT;
17 import dwt.internal.image.PngFileReadState;
18 import dwt.internal.image.PngIhdrChunk;
19 import dwt.internal.image.PngChunk;
20
21 class PngIendChunk : PngChunk {
22
23 this() {
24     super(0);
25     setType(TYPE_IEND);
26     setCRC(computeCRC());
27 }
28
29 this(byte[] reference){
30     super(reference);
31 }
32
33 override int getChunkType() {
34     return CHUNK_IEND;
35 }
36
37 /**
38  * Answer whether the chunk is a valid IEND chunk.
39  */
40 override void validate(PngFileReadState readState, PngIhdrChunk headerChunk) {
41     // An IEND chunk is invalid if no IHDR has been read.
42     // Or if a palette is required and has not been read.
43     // Or if no IDAT chunk has been read.
44     if (!readState.readIHDR
45         || (headerChunk.getMustHavePalette() && !readState.readPLTE)
46         || !readState.readIDAT
47         || readState.readIEND)
48     {
49         DWT.error(DWT.ERROR_INVALID_IMAGE);
50     } else {
51         readState.readIEND = true;
52     }
53
54     super.validate(readState, headerChunk);
55
56     // IEND chunks are not allowed to have any data.
57     if (getLength() > 0) DWT.error(DWT.ERROR_INVALID_IMAGE);
58 }
59
60 }
Note: See TracBrowser for help on using the browser.