< prev index next >
src/java.desktop/share/classes/com/sun/imageio/plugins/png/PNGImageReader.java
Print this page
*** 737,746 ****
--- 737,757 ----
switch (chunkType) {
case IDAT_TYPE:
// If chunk type is 'IDAT', we've reached the image data.
if (imageStartPosition == -1L) {
/*
+ * PNG specification mandates that if colorType is
+ * PNG_COLOR_PALETTE then PLTE chunk should appear
+ * before the first IDAT chunk.
+ */
+ if (colorType == PNG_COLOR_PALETTE &&
+ !(metadata.PLTE_present))
+ {
+ throw new IIOException("PNG image doesn't contain"
+ + " required PLTE chunk");
+ }
+ /*
* PNGs may contain multiple IDAT chunks containing
* a portion of image data. We store the position of
* the first IDAT chunk and continue with iteration
* of other chunks that follow image data.
*/
< prev index next >