Mercurial > projects > dwt-mac
diff dwt/internal/image/PngChunkReader.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 | e831403a80a9 |
children |
line wrap: on
line diff
--- a/dwt/internal/image/PngChunkReader.d Fri Sep 12 13:53:21 2008 +0200 +++ b/dwt/internal/image/PngChunkReader.d Sun Sep 14 01:45:57 2008 +0200 @@ -1,4 +1,4 @@ -/******************************************************************************* +/******************************************************************************* * Copyright (c) 2000, 2006 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 @@ -7,18 +7,26 @@ * * Contributors: * IBM Corporation - initial API and implementation + * Port to the D programming language: + * Frank Benoit <benoit@tionex.de> *******************************************************************************/ -module dwt.internal.image; +module dwt.internal.image.PngChunkReader; import dwt.DWT; +import dwt.internal.image.LEDataInputStream; +import dwt.internal.image.PngFileReadState; +import dwt.internal.image.PngIhdrChunk; +import dwt.internal.image.PngPlteChunk; +import dwt.internal.image.PngTrnsChunk; +import dwt.internal.image.PngChunk; public class PngChunkReader { LEDataInputStream inputStream; PngFileReadState readState; PngIhdrChunk headerChunk; PngPlteChunk paletteChunk; - + this(LEDataInputStream inputStream) { this.inputStream = inputStream; readState = new PngFileReadState(); @@ -27,12 +35,12 @@ PngIhdrChunk getIhdrChunk() { if (headerChunk is null) { - try { - PngChunk chunk = PngChunk.readNextFromStream(inputStream); - if (chunk is null) DWT.error(DWT.ERROR_INVALID_IMAGE); - headerChunk = cast(PngIhdrChunk) chunk; + PngChunk chunk = PngChunk.readNextFromStream(inputStream); + if (chunk is null) DWT.error(DWT.ERROR_INVALID_IMAGE); + if(( headerChunk = cast(PngIhdrChunk) chunk ) !is null ){ headerChunk.validate(readState, null); - } catch (ClassCastException e) { + } + else{ DWT.error(DWT.ERROR_INVALID_IMAGE); } } @@ -41,7 +49,7 @@ PngChunk readNextChunk() { if (headerChunk is null) return getIhdrChunk(); - + PngChunk chunk = PngChunk.readNextFromStream(inputStream); if (chunk is null) DWT.error(DWT.ERROR_INVALID_IMAGE); switch (chunk.getChunkType()) {