|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectar.com.hjg.pngj.PngReader
public class PngReader
Reads a PNG image, line by line
The reading sequence is as follows:
1. At construction time, the header and IHDR chunk are read (basic image info)
2. Optional: If you call GetMetadata() before reading the rows, the chunks before IDAT are automatically loaded
3. The rows are read in strict sequence, from 0 to nrows-1
4. The reading of the last row triggers the loading of trailing chunks, and ends the reader.
Field Summary | |
---|---|
ImageInfo |
imgInfo
Basic image info - final and inmutable. |
Constructor Summary | |
---|---|
PngReader(InputStream inputStream,
String filenameOrDescription)
Constructs a PngReader from an InputStream. |
Method Summary | |
---|---|
void |
end()
Normally this does nothing, but it can be used to force a premature closing |
ChunkLoadBehaviour |
getChunkLoadBehaviour()
|
ChunksList |
getChunksList()
All loaded chunks. |
int |
getCurrentChunkGroup()
|
PngMetadata |
getMetadata()
High level wrapper over chunksList |
ImageLine |
getRow(int nrow)
Like readRow(int nrow) but this accepts non consecutive rows. |
ImageLine |
readRow(int nrow)
Calls readRow(int[] buffer, int nrow) using internal ImageLine as buffer. |
int[] |
readRow(int[] buffer,
int nrow)
Reads a line and returns it as a int[] array. |
void |
setChunkLoadBehaviour(ChunkLoadBehaviour chunkLoadBehaviour)
|
void |
setMaxBytesChunksToLoad(int maxBytesChunksToLoad)
Total maximum bytes to load from ancillary ckunks (default: 1Mb) If exceeded, chunks will be ignored |
void |
setShouldCloseStream(boolean shouldCloseStream)
if true, input stream will be closed after ending read default=true |
String |
toString()
Basic info, for debugging. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public final ImageInfo imgInfo
Constructor Detail |
---|
public PngReader(InputStream inputStream, String filenameOrDescription)
See also FileHelper.createPngReader(File f)
if available.
Reads only the signature and first chunk (IDHR)
filenameOrDescription
- : Optional, can be a filename or a description. Just for error/debug messagesMethod Detail |
---|
public void end()
public ChunkLoadBehaviour getChunkLoadBehaviour()
public ChunksList getChunksList()
Critical chunks are included, except that all IDAT chunks appearance are replaced by a single dummy-marker IDAT chunk. These might be copied to the PngWriter
public int getCurrentChunkGroup()
public PngMetadata getMetadata()
public ImageLine getRow(int nrow)
readRow(int nrow)
but this accepts non consecutive rows.
If it's the current row, it will just return it. Elsewhere, it will try to read it. This implementation only accepts nrow greater or equal than current row, but an extended class could implement some partial or full cache of lines.
This should not not be mixed with calls to readRow(int[] buffer, final int nrow)
nrow
-
public ImageLine readRow(int nrow)
readRow(int[] buffer, int nrow)
using internal ImageLine as buffer. This doesn't allocate or
copy anything.
public int[] readRow(int[] buffer, int nrow)
You can pass (optionally) a prealocatted buffer.
buffer
- Prealocated buffer, or null.nrow
- Row number (0 is top). This is mostly for checking, because this library reads rows in sequence.
public void setChunkLoadBehaviour(ChunkLoadBehaviour chunkLoadBehaviour)
public void setMaxBytesChunksToLoad(int maxBytesChunksToLoad)
If exceeded, chunks will be ignored
public void setShouldCloseStream(boolean shouldCloseStream)
default=true
public String toString()
toString
in class Object
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |