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 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 DeflatedChunksSet |
createIdatSet(String id)
check that the last inserted chunk had the correct ordering
|
boolean |
firstChunksNotYetRead() |
long |
getBytesChunksLoaded() |
List<PngChunk> |
getChunks() |
Set<String> |
getChunksToSkip() |
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.
|
checkSignature, createChunkReaderForNewChunk, endChunkId, feedAll, feedFromFile, feedFromInputStream, feedFromInputStream, firstChunkId, getBytesCount, getChunkCount, getCurChunkReader, getCurReaderDeflatedSet, getIdatBytes, isAtChunkBoundary, isDone, isSignatureDoneprotected ImageInfo imageInfo
protected Deinterlacer deinterlacer
protected int currentChunkGroup
protected ChunksList chunksList
protected final boolean callbackMode
public boolean shouldSkipContent(int len,
String id)
ChunkSeqReadershouldSkipContent in class ChunkSeqReaderpublic long getBytesChunksLoaded()
public int getCurrentChunkGroup()
public void setChunksToSkip(String... chunksToSkip)
public void addChunkToSkip(String chunkToSkip)
public boolean firstChunksNotYetRead()
protected void postProcessChunk(ChunkReader chunkR)
ChunkSeqReaderpostProcessChunk in class ChunkSeqReaderprotected DeflatedChunksSet createIdatSet(String id)
createIdatSet in class ChunkSeqReaderpublic IdatSet getIdatSet()
protected boolean isIdatKind(String id)
ChunkSeqReaderisIdatKind in class ChunkSeqReaderpublic int consume(byte[] buf,
int off,
int len)
ChunkSeqReaderChunkSeqReader.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 IBytesConsumerconsume in class ChunkSeqReaderoff - 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)
ChunkSeqReaderChunkSeqReader.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 ChunkSeqReaderpublic void close()
ChunkSeqReaderclose in class ChunkSeqReaderpublic 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 ChunkSeqReaderpublic boolean isCheckCrc()
public void setCheckCrc(boolean checkCrc)
public boolean isCallbackMode()
public void setChunkLoadBehaviour(ChunkLoadBehaviour chunkLoadBehaviour)
public void setIncludeNonBufferedChunks(boolean includeNonBufferedChunks)
includeNonBufferedChunks - Copyright © 2014. All rights reserved.