java.lang.Object
org.apache.commons.imaging.common.BinaryFileParser
org.apache.commons.imaging.formats.png.chunks.PngChunk
Direct Known Subclasses:
PngChunkGama, PngChunkIccp, PngChunkIdat, PngChunkIhdr, PngChunkPhys, PngChunkPlte, PngChunkScal, PngTextChunk

public class PngChunk extends BinaryFileParser
A PNG image is composed of several chunks. This is the base class for the chunks, used by the parser.
  • Field Details

    • length

      public final int length
    • chunkType

      public final int chunkType
    • crc

      public final int crc
    • bytes

      private final byte[] bytes
    • propertyBits

      private final boolean[] propertyBits
    • ancillary

      public final boolean ancillary
    • isPrivate

      public final boolean isPrivate
    • reserved

      public final boolean reserved
    • safeToCopy

      public final boolean safeToCopy
  • Constructor Details

    • PngChunk

      public PngChunk(int length, int chunkType, int crc, byte[] bytes)
      Constructor.
      Parameters:
      length - chunk length
      chunkType - chunk type
      crc - CRC computed over the chunk type and chunk data (but not the length)
      bytes - chunk data bytes
  • Method Details

    • getBytes

      public byte[] getBytes()
      Return a copy of the chunk bytes.
      Returns:
      the chunk bytes
    • getPropertyBits

      public boolean[] getPropertyBits()
      Return a copy of the chunk property bits.
      Returns:
      the chunk property bits
    • getDataStream

      protected ByteArrayInputStream getDataStream()
      Create and return a ByteArrayInputStream for the chunk bytes.

      The caller is responsible for closing the resource.

      Returns:
      a ByteArrayInputStream for the chunk bytes