diff --git a/Source/com/drew/imaging/png/PngChunkReader.java b/Source/com/drew/imaging/png/PngChunkReader.java index cbc4e5de5..c8a4db064 100644 --- a/Source/com/drew/imaging/png/PngChunkReader.java +++ b/Source/com/drew/imaging/png/PngChunkReader.java @@ -69,6 +69,12 @@ public Iterable extract(@NotNull final SequentialReader reader, @Nulla // Miscellaneous information: bKGD, hIST, pHYs, sPLT // Time information: tIME // + // CHUNK READING + // + // Only chunk data for types specified in desiredChunkTypes is extracted. + // For empty chunk type list NO data is copied from source stream. + // For null chunk type list ALL data is copied from source stream. + // reader.setMotorolaByteOrder(true); // network byte order @@ -93,7 +99,13 @@ public Iterable extract(@NotNull final SequentialReader reader, @Nulla boolean willStoreChunk = desiredChunkTypes == null || desiredChunkTypes.contains(chunkType); - byte[] chunkData = reader.getBytes(chunkDataLength); + byte[] chunkData; + if (willStoreChunk) { + chunkData = reader.getBytes(chunkDataLength); + } else { + chunkData = null; // To satisfy the compiler + reader.skip(chunkDataLength); + } // Skip the CRC bytes at the end of the chunk // TODO consider verifying the CRC value to determine if we're processing bad data