public class ChunkSeqReaderPng extends ChunkSeqReader
Most usual PNG reading should use this class, or a PngReader
, which is a thin wrapper over this.
Modifier and Type | Field and Description |
---|---|
protected boolean |
callbackMode |
protected ChunksList |
chunksList
All chunks, but some of them can have the buffer empty (IDAT and skipped)
|
protected ImageInfo |
curImageInfo |
protected int |
currentChunkGroup |
protected Deinterlacer |
deinterlacer |
protected ImageInfo |
imageInfo |
SIGNATURE_LEN, withSignature
Constructor and Description |
---|
ChunkSeqReaderPng(boolean callbackMode) |
Modifier and Type | Method and Description |
---|---|
void |
addChunkToSkip(String chunkToSkip) |
void |
close()
Closes this object and release resources.
|
int |
consume(byte[] buf,
int off,
int len)
Consumes (in general, partially) a number of bytes.
|
protected boolean |
countChunkTypeAsAncillary(String id) |
protected DeflatedChunksSet |
createIdatSet(String id)
DeflatedChunksSet factory.
|
void |
dontSkipChunk(String chunkToSkip) |
boolean |
firstChunksNotYetRead() |
long |
getBytesChunksLoaded() |
List<PngChunk> |
getChunks() |
Set<String> |
getChunksToSkip() |
ImageInfo |
getCurImgInfo() |
int |
getCurrentChunkGroup() |
Deinterlacer |
getDeinterlacer() |
IdatSet |
getIdatSet() |
ImageInfo |
getImageInfo() |
long |
getMaxBytesMetadata() |
long |
getMaxTotalBytesRead() |
long |
getSkipChunkMaxSize() |
boolean |
isCallbackMode() |
boolean |
isCheckCrc() |
protected boolean |
isIdatKind(String id)
Decides if this Chunk is of "IDAT" kind (in concrete: if it is, and if it's not to be skiped, a DeflatedChunksSet
will be created to deflate it and process+ the deflated data)
This implementation always returns always false
|
boolean |
isInterlaced() |
protected void |
postProcessChunk(ChunkReader chunkR)
This is called after a chunk is read, in all modes
This implementation only chenks the id of the first chunk, and process the IEND chunk (sets done=true)
Further processing should be overriden (call this first!)
|
protected void |
processEndPng()
Things to be done after IEND processing.
|
void |
setCheckCrc(boolean checkCrc) |
void |
setChunkFactory(IChunkFactory chunkFactory)
sets a custom chunk factory.
|
void |
setChunkLoadBehaviour(ChunkLoadBehaviour chunkLoadBehaviour) |
void |
setChunksToSkip(String... chunksToSkip) |
void |
setIncludeNonBufferedChunks(boolean includeNonBufferedChunks)
If true, the chunks with no data (because skipped or because processed like IDAT-type) are still stored in the
PngChunks list, which might be more informative.
|
void |
setMaxBytesMetadata(long maxBytesMetadata) |
void |
setMaxTotalBytesRead(long maxTotalBytesRead) |
void |
setSkipChunkMaxSize(long skipChunkMaxSize) |
protected boolean |
shouldCheckCrc(int len,
String id) |
boolean |
shouldSkipContent(int len,
String id)
Chunks can be skipped depending on id and/or length.
|
protected void |
startNewChunk(int len,
String id,
long offset)
Called for all chunks when a chunk start has been read (id and length), before the chunk data itself is read.
|
void |
updateCurImgInfo(ImageInfo iminfo) |
checkSignature, createChunkReaderForNewChunk, endChunkId, feedAll, feedFromFile, feedFromInputStream, feedFromInputStream, firstChunkId, getBytesCount, getChunkCount, getCurChunkReader, getCurReaderDeflatedSet, getIdatBytes, isAtChunkBoundary, isDone, isSignatureDone
protected ImageInfo imageInfo
protected ImageInfo curImageInfo
protected Deinterlacer deinterlacer
protected int currentChunkGroup
protected ChunksList chunksList
protected final boolean callbackMode
public boolean shouldSkipContent(int len, String id)
ChunkSeqReader
shouldSkipContent
in class ChunkSeqReader
public long getBytesChunksLoaded()
public int getCurrentChunkGroup()
public void setChunksToSkip(String... chunksToSkip)
public void addChunkToSkip(String chunkToSkip)
public void dontSkipChunk(String chunkToSkip)
public boolean firstChunksNotYetRead()
protected void postProcessChunk(ChunkReader chunkR)
ChunkSeqReader
postProcessChunk
in class ChunkSeqReader
protected boolean countChunkTypeAsAncillary(String id)
protected DeflatedChunksSet createIdatSet(String id)
ChunkSeqReader
createIdatSet
in class ChunkSeqReader
public IdatSet getIdatSet()
protected boolean isIdatKind(String id)
ChunkSeqReader
isIdatKind
in class ChunkSeqReader
public int consume(byte[] buf, int off, int len)
ChunkSeqReader
ChunkSeqReader.startNewChunk(int, String, long)
When data from a chunk is being read, it delegates to ChunkReader.feedBytes(byte[], int, int)
The caller might want to call this method more than once in succesion
This should rarely be overridenconsume
in interface IBytesConsumer
consume
in class ChunkSeqReader
off
- Offset in bufferlen
- Valid bytes that can be consumedpublic void setChunkFactory(IChunkFactory chunkFactory)
chunkFactory
- protected void processEndPng()
public ImageInfo getImageInfo()
public boolean isInterlaced()
public Deinterlacer getDeinterlacer()
protected void startNewChunk(int len, String id, long offset)
ChunkSeqReader
ChunkSeqReader.getCurChunkReader()
) in the corresponding mode, and
eventually a curReaderDeflatedSet.(field accesible via ChunkSeqReader.getCurReaderDeflatedSet()
)
To decide the mode and options, it calls ChunkSeqReader.shouldCheckCrc(int, String)
,
ChunkSeqReader.shouldSkipContent(int, String)
, ChunkSeqReader.isIdatKind(String)
. Those methods should be overriden in
preference to this; if overriden, this should be called first.
The respective ChunkReader.chunkDone()
method is directed to this ChunkSeqReader.postProcessChunk(ChunkReader)
.
Instead of overriding this, see also ChunkSeqReader.createChunkReaderForNewChunk(String, int, long, boolean)
startNewChunk
in class ChunkSeqReader
public void close()
ChunkSeqReader
close
in class ChunkSeqReader
public void setMaxTotalBytesRead(long maxTotalBytesRead)
public long getSkipChunkMaxSize()
public void setSkipChunkMaxSize(long skipChunkMaxSize)
public long getMaxBytesMetadata()
public void setMaxBytesMetadata(long maxBytesMetadata)
public long getMaxTotalBytesRead()
protected boolean shouldCheckCrc(int len, String id)
shouldCheckCrc
in class ChunkSeqReader
public boolean isCheckCrc()
public void setCheckCrc(boolean checkCrc)
public boolean isCallbackMode()
public void setChunkLoadBehaviour(ChunkLoadBehaviour chunkLoadBehaviour)
public ImageInfo getCurImgInfo()
public void updateCurImgInfo(ImageInfo iminfo)
public void setIncludeNonBufferedChunks(boolean includeNonBufferedChunks)
includeNonBufferedChunks
- Copyright © 2014. All rights reserved.