Package net.sourceforge.jiu.codecs

# Class PngIdatInputStream

java.lang.Object
java.io.InputStream
net.sourceforge.jiu.codecs.PngIdatInputStream

All Implemented Interfaces:
  `Closeable`, `AutoCloseable`

class PngIdatInputStream extends InputStream
An input stream that reads from an underlying stream of PNG IDAT chunks and skips all header information. PNG uses one or more IDAT chunks to store image data. The resulting stream looks like that: `IDAT [chunk size] [compressed data] [checksum] IDAT [chunk size] [compressed data] [checksum] ...` This stream class expects an input stream where the first IDAT chunk name and chunk size have been read already, the stream is thus pointing to the first byte of the first [compressed data] section. The size of that section is given to the constructor. This class then returns calls to read(), counts the bytes it has given away and, whenever a compressed data section has been consumed, it reads the IDAT chunk and stores its size, using it to determine when the next compressed data section will end. That way, for the caller the stream appears to be one large compressed section.

According to the PNG specs the reason for multiple IDAT chunks is as follows:

> (Multiple IDAT chunks are allowed so that encoders can work in a fixed amount of memory; typically the chunk size will correspond to the encoder's buffer size.)

4.1.3. IDAT Image data

If there is a more elegant approach to read multiple IDAT chunks, please let me know. However, reading everything into memory is not an option.

Since:
  0.12.0
Author:
  Marco Schmidt

## Field Summary

Fields
Modifier and Type
Field
Description
`private long`
`bytesLeft`
`private static final int`
`IDAT`
`private DataInputStream`
`in`

## Constructor Summary

Constructors
Constructor
Description
`PngIdatInputStream(DataInputStream input, long bytes)`

## Method Summary

Modifier and Type
Method
Description
`int`
`read()`
`private void`
`skipHeaders()`

### Methods inherited from class java.io.InputStream

`available, close, mark, markSupported, nullInputStream, read, read, readAllBytes, readNBytes, readNBytes, reset, skip, skipNBytes, transferTo`

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

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

## Field Details

### IDAT

private static final int IDAT

See Also:
  - Constant Field Values

### in

private DataInputStream in

### bytesLeft

private long bytesLeft

## Constructor Details

### PngIdatInputStream

public PngIdatInputStream(DataInputStream input, long bytes)

## Method Details

### read

public int read() throws IOException

Specified by:
  `read` in class `InputStream`
Throws:
  `IOException`

### skipHeaders

private void skipHeaders() throws IOException

Throws:
  `IOException`