public class DeflatedChunksSet extends Object
The inflated stream is intented to be read as a sequence of "rows", of which the caller knows the lengths (not necessary equal) and number.
Eg: For IDAT non-interlaced images, a row has bytesPerRow + 1 filter byte
For interlaced images, the lengths are variable.
This class can work in sync (polled) mode or async (callback) mode
See IdatSet, which is mostly used and has a slightly simpler use.
See DeflatedChunkSetTest for example of use.
| Modifier and Type | Field and Description |
|---|---|
String |
chunkid
All IDAT-like chunks that form a same DeflatedChunksSet should have the
same id
|
protected byte[] |
row |
| Constructor and Description |
|---|
DeflatedChunksSet(String chunkid,
int initialRowLen,
int maxRowLen) |
DeflatedChunksSet(String chunkid,
int initialRowLen,
int maxRowLen,
Inflater inflater,
byte[] buffer) |
| Modifier and Type | Method and Description |
|---|---|
boolean |
allowOtherChunksInBetween(String id)
Some IDAT-like set can allow other chunks in between (APGN?).
|
protected void |
appendNewChunk(DeflatedChunkReader cr) |
void |
end()
this should be called only when discarding this object, or for aborting
|
byte[] |
getInflatedRow()
Inflated buffer.
|
int |
getnFedBytes()
total number of bytes that have been fed to this object
|
int |
getRowFilled()
This the amount of valid bytes in the buffer
|
int |
getRowLen()
Target size of the current row, including filter byte.
|
int |
getRown()
Get current (last) row number.
|
boolean |
isCallbackMode()
Callback mode = async processing
|
boolean |
isDone()
In this state, all relevant data has been uncompressed and retrieved.
|
boolean |
isRowReady()
In this state, the object is waiting the caller to retrieve inflated data
|
boolean |
isWaitingForMoreInput()
In this state, the object is waiting for more input to deflate.
|
protected void |
prepareForNextRow(int len)
Should be called after the previous row was processed
|
protected void |
preProcessRow()
Called automatically in all modes when a full row has been inflated.
|
protected void |
processBytes(byte[] buf,
int off,
int len)
Feeds the inflater with the compressed bytes
In poll mode, the caller should not call repeatedly this, without
consuming first, checking isDataReadyForConsumer()
|
protected int |
processRowCallback()
callback, must be implemented in callbackMode Must return byes of next
row, for next callback
|
void |
setCallbackMode(boolean callbackMode) |
String |
toString() |
protected byte[] row
public final String chunkid
public DeflatedChunksSet(String chunkid, int initialRowLen, int maxRowLen, Inflater inflater, byte[] buffer)
initialRowLen - Length in bytes of first "row" (see description)maxRowLen - Max length in bytes of "rows"inflater - Can be null. If not null, will be resetpublic DeflatedChunksSet(String chunkid, int initialRowLen, int maxRowLen)
protected void appendNewChunk(DeflatedChunkReader cr)
protected void processBytes(byte[] buf,
int off,
int len)
buf - off - len - protected void preProcessRow()
protected int processRowCallback()
public byte[] getInflatedRow()
getRowFilled()protected void prepareForNextRow(int len)
Pass 0 or negative to signal that we are done (not expecting more bytes)
This resets rowfilled
public boolean isWaitingForMoreInput()
Only in this state it's legal to feed this
public boolean isRowReady()
Effective length: see getRowFilled()
public boolean isDone()
We can still feed this object, but the bytes will be swallowed/ignored.
public void end()
public int getRowLen()
public int getRowFilled()
public int getRown()
This corresponds to the raw numeration of rows as seen by the deflater. Not the same as the real image row, if interlaced.
public boolean allowOtherChunksInBetween(String id)
Normally false.
id - Id of the other chunk that appeared in middel of this set.public boolean isCallbackMode()
public void setCallbackMode(boolean callbackMode)
public int getnFedBytes()
Copyright © 2013. All rights reserved.