|
||||||||
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() or getChunksLisk() before start reading the rows, the chunks before IDAT are automatically loaded
3. The rows are read in strict sequence, from 0 to nrows-1 (you can skip rows by calling getRow() )
4. Reading of the last row triggers the loading of trailing chunks, and ends the reader.
5. end() forcibly finishes/aborts the reading and closes the stream
Field Summary | |
---|---|
ImageInfo |
imgInfo
Basic image info - final and inmutable. |
Constructor Summary | |
---|---|
PngReader(java.io.InputStream inputStream,
java.lang.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()
|
int |
getMaxBytesMetadata()
|
long |
getMaxTotalBytesRead()
|
PngMetadata |
getMetadata()
High level wrapper over chunksList |
ImageLine |
getRow(int nrow)
Like readRow(int nrow) but this accepts non consecutive rows. |
java.lang.String[] |
getSkipChunkIds()
|
int |
getSkipChunkMaxSize()
|
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 |
setMaxBytesMetadata(int maxBytesChunksToLoad)
Set total maximum bytes to load from ancillary chunks (default: 5Mb). |
void |
setMaxTotalBytesRead(long maxTotalBytesToRead)
Set total maximum bytes to read (default: 200MB). |
void |
setShouldCloseStream(boolean shouldCloseStream)
if true, input stream will be closed after ending read default=true |
void |
setSkipChunkIds(java.lang.String[] skipChunksById)
Chunks ids to be skipped. |
void |
setSkipChunkMaxSize(int skipChunksBySize)
Set maximum size in bytes for individual ancillary chunks (default: 2MB). |
java.lang.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(java.io.InputStream inputStream, java.lang.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 int getMaxBytesMetadata()
public long getMaxTotalBytesRead()
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 java.lang.String[] getSkipChunkIds()
public int getSkipChunkMaxSize()
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 setMaxBytesMetadata(int maxBytesChunksToLoad)
public void setMaxTotalBytesRead(long maxTotalBytesToRead)
public void setShouldCloseStream(boolean shouldCloseStream)
default=true
public void setSkipChunkIds(java.lang.String[] skipChunksById)
public void setSkipChunkMaxSize(int skipChunksBySize)
public java.lang.String toString()
toString
in class java.lang.Object
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |