comparison dwt/internal/image/PngIendChunk.d @ 0:380af2bdd8e5

Upload of whole dwt tree
author Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
date Sat, 09 Aug 2008 17:00:02 +0200
parents
children 1a8b3cb347e0
comparison
equal deleted inserted replaced
-1:000000000000 0:380af2bdd8e5
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 *******************************************************************************/
11 module dwt.internal.image;
12
13
14 import dwt.DWT;
15
16 class PngIendChunk : PngChunk {
17
18 PngIendChunk() {
19 super(0);
20 setType(TYPE_IEND);
21 setCRC(computeCRC());
22 }
23
24 PngIendChunk(byte[] reference){
25 super(reference);
26 }
27
28 int getChunkType() {
29 return CHUNK_IEND;
30 }
31
32 /**
33 * Answer whether the chunk is a valid IEND chunk.
34 */
35 void validate(PngFileReadState readState, PngIhdrChunk headerChunk) {
36 // An IEND chunk is invalid if no IHDR has been read.
37 // Or if a palette is required and has not been read.
38 // Or if no IDAT chunk has been read.
39 if (!readState.readIHDR
40 || (headerChunk.getMustHavePalette() && !readState.readPLTE)
41 || !readState.readIDAT
42 || readState.readIEND)
43 {
44 DWT.error(DWT.ERROR_INVALID_IMAGE);
45 } else {
46 readState.readIEND = true;
47 }
48
49 super.validate(readState, headerChunk);
50
51 // IEND chunks are not allowed to have any data.
52 if (getLength() > 0) DWT.error(DWT.ERROR_INVALID_IMAGE);
53 }
54
55 }