Package org.apache.commons.imaging.formats.png.chunks

# Class PngChunk

java.lang.Object
org.apache.commons.imaging.common.BinaryFileParser
org.apache.commons.imaging.formats.png.chunks.PngChunk

Direct Known Subclasses:
  `AbstractPngTextChunk`, `PngChunkGama`, `PngChunkIccp`, `PngChunkIdat`, `PngChunkIhdr`, `PngChunkPhys`, `PngChunkPlte`, `PngChunkScal`

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.

See Also:
  - Portable_Network_Graphics

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `PngChunk(int length, int chunkType, int crc, byte[] bytes)`
  Constructs a new instance.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `byte[]`
  `getBytes()`
  Gets a copy of the chunk bytes.
  `int`
  `getChunkType()`
  `int`
  `getCrc()`
  `protected ByteArrayInputStream`
  `getDataStream()`
  Gets a new `ByteArrayInputStream` for the chunk bytes.
  `int`
  `getLength()`
  `boolean[]`
  `getPropertyBits()`
  Gets a copy of the chunk property bits.
  `boolean`
  `isAncillary()`
  `boolean`
  `isPrivate()`
  `boolean`
  `isReserved()`
  `boolean`
  `isSafeToCopy()`

  ### Methods inherited from class org.apache.commons.imaging.common.BinaryFileParser

  `debugNumber, debugNumber, getByteOrder, setByteOrder`

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Constructor Details

  - ### PngChunk

    public PngChunk(int length, int chunkType, int crc, byte[] bytes)
    Constructs a new instance.
    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.
    Throws:
      `NullPointerException` - if `bytes` is null.

- ## Method Details

  - ### getBytes

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

  - ### getChunkType

    public int getChunkType()

  - ### getCrc

    public int getCrc()

  - ### getDataStream

    protected ByteArrayInputStream getDataStream()
    Gets a new `ByteArrayInputStream` for the chunk bytes.

    The caller is responsible for closing the resource.

    Returns:
      a ByteArrayInputStream for the chunk bytes

  - ### getLength

    public int getLength()

  - ### getPropertyBits

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

  - ### isAncillary

    public boolean isAncillary()

  - ### isPrivate

    public boolean isPrivate()

  - ### isReserved

    public boolean isReserved()

  - ### isSafeToCopy

    public boolean isSafeToCopy()