public abstract class PixelsWriter extends Object
This includes the filter selection strategy, plus the filtering itself and the deflating. Only supports fixed length rows (no interlaced writing).
Typically an instance of this is hold by a PngWriter - but more instances could be used (for APGN)
Modifier and Type | Field and Description |
---|---|
protected int |
buflen
row buffer length, including filter byte (imgInfo.bytesPerRow + 1)
|
protected int |
bytesPixel |
protected int |
bytesRow |
protected int |
currentRow
row being processed, couting from zero
|
protected int |
deflaterCompLevel |
protected int |
deflaterStrategy |
protected FilterType |
filterType
This is the globally configured filter type - it can be a concrete type or a pseudo type (hint or strategy)
|
protected ImageInfo |
imgInfo |
protected boolean |
initdone |
Constructor and Description |
---|
PixelsWriter(ImageInfo imgInfo) |
Modifier and Type | Method and Description |
---|---|
void |
close()
cleanup.
|
protected abstract void |
filterAndWrite(byte[] rowb)
This does the filtering and send to stream.
|
protected byte[] |
filterRowWithFilterType(FilterType _filterType,
byte[] _rowb,
byte[] _rowbprev,
byte[] _rowf)
Does the real filtering.
|
double |
getCompression() |
protected FilterType |
getDefaultFilter()
computed default fixed filter type to use, if specified DEFAULT; wilde guess based on image properties
|
Integer |
getDeflaterCompLevel() |
String |
getFiltersUsed()
informational stats : filter used, in percentages
|
FilterType |
getFilterType() |
OutputStream |
getOs() |
abstract byte[] |
getRowb()
This will be called by the PngWrite to fill the raw pixels for each row.
|
long |
getTotalBytesToWrite() |
protected void |
init()
This will be called lazily just before writing row 0.
|
protected void |
initParams()
called by init(); override (calling this first) to do additional initialization
|
boolean |
isDone() |
void |
processRow(byte[] rowb)
main internal point for external call.
|
protected void |
sendToCompressedStream(byte[] rowf) |
void |
setCompressorStream(CompressorStream compressorStream) |
void |
setDeflaterCompLevel(Integer deflaterCompLevel)
Deflater (ZLIB) compression level, between 0 (no compression) and 9
|
void |
setDeflaterStrategy(Integer deflaterStrategy)
Deflater (ZLIB) strategy.
|
void |
setFilterType(FilterType filterType) |
void |
setIdatMaxSize(int idatMaxSize) |
void |
setOs(OutputStream datStream) |
protected final ImageInfo imgInfo
protected final int buflen
protected final int bytesPixel
protected final int bytesRow
protected int deflaterCompLevel
protected int deflaterStrategy
protected boolean initdone
protected FilterType filterType
protected int currentRow
public PixelsWriter(ImageInfo imgInfo)
public final void processRow(byte[] rowb)
filterAndWrite(byte[])
protected void sendToCompressedStream(byte[] rowf)
protected abstract void filterAndWrite(byte[] rowb)
filterRowWithFilterType(FilterType, byte[], byte[], byte[])
and and
sendToCompressedStream(byte[])
rowb
- protected final byte[] filterRowWithFilterType(FilterType _filterType, byte[] _rowb, byte[] _rowbprev, byte[] _rowf)
WARNING: look out the contract
_filterType
- _rowb
- current row (the first byte might be modified)_rowbprev
- previous row (should be all zero the first time)_rowf
- tentative buffer to store the filtered bytes. might not be used!public abstract byte[] getRowb()
protected final void init()
protected void initParams()
public void close()
public void setDeflaterStrategy(Integer deflaterStrategy)
public void setDeflaterCompLevel(Integer deflaterCompLevel)
public Integer getDeflaterCompLevel()
public final void setOs(OutputStream datStream)
public OutputStream getOs()
public final FilterType getFilterType()
filterType
public final void setFilterType(FilterType filterType)
filterType
public double getCompression()
public void setCompressorStream(CompressorStream compressorStream)
public long getTotalBytesToWrite()
public boolean isDone()
protected FilterType getDefaultFilter()
public final String getFiltersUsed()
public void setIdatMaxSize(int idatMaxSize)
Copyright © 2014. All rights reserved.