| Modifier and Type | Field and Description |
|---|---|
| private final ChunksListForWrite | |
| private int | compLevel
zip compression level 0 - 9 |
| protected int | |
| private PngIDatChunkOutputStream | |
| private DeflaterOutputStream | |
| private int | deflaterStrategy
Deflate algortithm compression strategy |
| private final String | |
| protected FilterWriteStrategy | filterStrat
PNG filter strategy |
| private final int[] | |
| private int | |
| public final ImageInfo | |
| private final PngMetadata | |
| private final OutputStream | |
| protected byte[] | |
| protected byte[] | |
| protected byte[] | |
| protected int | rowNum
last read row number, starting from 0 |
| private boolean | |
| private boolean |
| Access | Constructor and Description |
|---|---|
| public | |
| public | PngWriter(final OutputStream
Opened stream for binary writing outputStream, final ImageInfo Basic image parameters imgInfo, final String Optional, just for error/debug messages filenameOrDescription)Constructs a new PngWriter from a output stream. |
| Modifier and Type | Method and Description |
|---|---|
| public double | |
| private void | copyChunks(final PngReader reader, final int copy_mask, final boolean onlyAfterIdat)
copy chunks from reader - copy_mask : see ChunksToWrite.COPY_XXX If we are after idat, only considers those chunks after IDAT in PngReader Todo this should be more customizable |
| public void | copyChunksFirst(final PngReader
: PngReader object, already opened. reader, final int : Mask bit (OR), see copy_mask)ChunksToWrite.COPY_XXX
constantsCopies first (pre IDAT) ancillary chunks from a PngReader. |
| public void | copyChunksLast(final PngReader
: PngReader object, already opened and fully read. reader, final int : Mask bit (OR), see copy_mask)ChunksToWrite.COPY_XXX
constantsCopies last (post IDAT) ancillary chunks from a PngReader. |
| protected void | |
| protected void | |
| public void | |
| private void | |
| private void | |
| protected void | |
| protected void | |
| protected void | |
| protected void | |
| protected void | |
| public ChunksListForWrite | |
| public String | |
| public PngMetadata | |
| private void | |
| public boolean | |
| private void | |
| private void | |
| public void | setCompLevel(final int
between 0 and 9 (default:6 , recommended: 6 or more) compLevel)Sets compression level of ZIP algorithm. |
| public void | setDeflaterStrategy(final int deflaterStrategy)
Deflater strategy: one of Deflater.FILTERED Deflater.HUFFMAN_ONLY Deflater.DEFAULT_STRATEGY Default: Deflater.FILTERED . |
| public void | setFilterType(final FilterType
One of the five prediction types or strategy to choose it (see
filterType)PngFilterType) Recommended values: DEFAULT
(default) or AGGRESIVESets internal prediction filter type, or strategy to choose it. |
| public void | setIdatMaxSize(final int
default=0 : use defaultSize (32K) idatMaxSize)Sets maximum size of IDAT fragments. |
| public void | setShouldCloseStream(final boolean shouldCloseStream)
if true, input stream will be closed after ending write default=true |
| public void | setUseUnPackedMode(final boolean useUnpackedMode)
If false (default), and image has bitdepth 1-2-4, the scanlines passed are assumed to be already packed. |
| protected int | |
| private void | |
| private void | |
| private void | |
| public void | |
| public void | |
| public void | |
| public void | |
| public void | |
| public void | writeRowInt(final int[]
Array of pixel values. newrow, final int Warning the array size should be exact (samplesPerRowP) Row number, from 0 (top) to rows-1 (bottom). This is just used
as a check. Pass -1 if you want to autocompute it rown)Writes a full image row. |
| public void | |
| public void | |
| private void |
| chunksList | back to summary |
|---|---|
| private final ChunksListForWrite chunksList | |
| compLevel | back to summary |
|---|---|
| private int compLevel zip compression level 0 - 9 | |
| currentChunkGroup | back to summary |
|---|---|
| protected int currentChunkGroup Current chunk grounp, (0-6) already read or reading
see | |
| datStream | back to summary |
|---|---|
| private PngIDatChunkOutputStream datStream | |
| datStreamDeflated | back to summary |
|---|---|
| private DeflaterOutputStream datStreamDeflated | |
| deflaterStrategy | back to summary |
|---|---|
| private int deflaterStrategy Deflate algortithm compression strategy | |
| filename | back to summary |
|---|---|
| private final String filename | |
| filterStrat | back to summary |
|---|---|
| protected FilterWriteStrategy filterStrat PNG filter strategy | |
| histox | back to summary |
|---|---|
| private final int[] histox | |
| idatMaxSize | back to summary |
|---|---|
| private int idatMaxSize | |
| imgInfo | back to summary |
|---|---|
| public final ImageInfo imgInfo | |
| metadata | back to summary |
|---|---|
| private final PngMetadata metadata | |
| os | back to summary |
|---|---|
| private final OutputStream os | |
| rowb | back to summary |
|---|---|
| protected byte[] rowb | |
| rowbfilter | back to summary |
|---|---|
| protected byte[] rowbfilter | |
| rowbprev | back to summary |
|---|---|
| protected byte[] rowbprev | |
| rowNum | back to summary |
|---|---|
| protected int rowNum last read row number, starting from 0 | |
| shouldCloseStream | back to summary |
|---|---|
| private boolean shouldCloseStream | |
| unpackedMode | back to summary |
|---|---|
| private boolean unpackedMode | |
| PngWriter | back to summary |
|---|---|
| public PngWriter(final OutputStream outputStream, final ImageInfo imgInfo) | |
| PngWriter | back to summary |
|---|---|
| public PngWriter(final OutputStream outputStream, final ImageInfo imgInfo, final String filenameOrDescription) Constructs a new PngWriter from a output stream. After construction nothing is writen yet. You still can set some parameters (compression, filters) and queue chunks before start writing the pixels.
See also
| |
| computeCompressionRatio | back to summary |
|---|---|
| public double computeCompressionRatio() Computes compressed size/raw size, approximate. Actually: compressed size = total size of IDAT data , raw size = uncompressed pixel bytes = rows * (bytesPerRow + 1). This must be called after pngw.end() | |
| copyChunks | back to summary |
|---|---|
| private void copyChunks(final PngReader reader, final int copy_mask, final boolean onlyAfterIdat) copy chunks from reader - copy_mask : see ChunksToWrite.COPY_XXX If we are after idat, only considers those chunks after IDAT in PngReader Todo this should be more customizable | |
| copyChunksFirst | back to summary |
|---|---|
| public void copyChunksFirst(final PngReader reader, final int copy_mask) Copies first (pre IDAT) ancillary chunks from a PngReader. Should be called when creating an image from another, before starting writing lines, to copy relevant chunks.
| |
| copyChunksLast | back to summary |
|---|---|
| public void copyChunksLast(final PngReader reader, final int copy_mask) Copies last (post IDAT) ancillary chunks from a PngReader. Should be called when creating an image from another, after writing all lines, before closing the writer, to copy additional chunks.
| |
| encodeRowFromByte | back to summary |
|---|---|
| protected void encodeRowFromByte(final byte[] row) | |
| encodeRowFromInt | back to summary |
|---|---|
| protected void encodeRowFromInt(final int[] row) | |
| end | back to summary |
|---|---|
| public void end() Finalizes the image creation and closes the stream. This MUST be called after writing the lines. | |
| filterAndSend | back to summary |
|---|---|
| private void filterAndSend(final int rown) | |
| filterRow | back to summary |
|---|---|
| private void filterRow(final int rown) | |
| filterRowAverage | back to summary |
|---|---|
| protected void filterRowAverage() | |
| filterRowNone | back to summary |
|---|---|
| protected void filterRowNone() | |
| filterRowPaeth | back to summary |
|---|---|
| protected void filterRowPaeth() | |
| filterRowSub | back to summary |
|---|---|
| protected void filterRowSub() | |
| filterRowUp | back to summary |
|---|---|
| protected void filterRowUp() | |
| getChunksList | back to summary |
|---|---|
| public ChunksListForWrite getChunksList() returns the chunks list (queued and writen chunks) | |
| getFilename | back to summary |
|---|---|
| public String getFilename() Filename or description, from the optional constructor argument. | |
| getMetadata | back to summary |
|---|---|
| public PngMetadata getMetadata() High level wrapper over chunksList for metadata handling | |
| init | back to summary |
|---|---|
| private void init() | |
| isUnpackedMode | back to summary |
|---|---|
| public boolean isUnpackedMode() | |
| prepareEncodeRow | back to summary |
|---|---|
| private void prepareEncodeRow(final int rown) | |
| reportResultsForFilter | back to summary |
|---|---|
| private void reportResultsForFilter(final int rown, final FilterType type, final boolean tentative) | |
| setCompLevel | back to summary |
|---|---|
| public void setCompLevel(final int compLevel) Sets compression level of ZIP algorithm. This must be called just after constructor, before starting writing. See also setFilterType()
| |
| setDeflaterStrategy | back to summary |
|---|---|
| public void setDeflaterStrategy(final int deflaterStrategy) Deflater strategy: one of Deflater.FILTERED Deflater.HUFFMAN_ONLY Deflater.DEFAULT_STRATEGY Default: Deflater.FILTERED . This should be changed very rarely. | |
| setFilterType | back to summary |
|---|---|
| public void setFilterType(final FilterType filterType) Sets internal prediction filter type, or strategy to choose it. This must be called just after constructor, before starting writing. See also setCompLevel()
| |
| setIdatMaxSize | back to summary |
|---|---|
| public void setIdatMaxSize(final int idatMaxSize) Sets maximum size of IDAT fragments. This has little effect on performance you should rarely call this
| |
| setShouldCloseStream | back to summary |
|---|---|
| public void setShouldCloseStream(final boolean shouldCloseStream) if true, input stream will be closed after ending write default=true | |
| setUseUnPackedMode | back to summary |
|---|---|
| public void setUseUnPackedMode(final boolean useUnpackedMode) If false (default), and image has bitdepth 1-2-4, the scanlines passed are assumed to be already packed. If true, each element is a sample, the writer will perform the packing if necessary. Warning when using | |
| sumRowbfilter | back to summary |
|---|---|
| protected int sumRowbfilter() | |
| writeEndChunk | back to summary |
|---|---|
| private void writeEndChunk() | |
| writeFirstChunks | back to summary |
|---|---|
| private void writeFirstChunks() | |
| writeLastChunks | back to summary |
|---|---|
| private void writeLastChunks() | |
| writeRow | back to summary |
|---|---|
| public void writeRow(final ImageLine imgline)
Deprecated Better use writeRow(ImageLine imgline, int rownumber) Writes line, checks that the row number is consistent with that of the ImageLine See writeRow(int[] newrow, int rown) | |
| writeRow | back to summary |
|---|---|
| public void writeRow(final ImageLine imgline, final int rownumber) Writes line. See writeRow(int[] newrow, int rown) The packed flag of the imageline is honoured!
| |
| writeRow | back to summary |
|---|---|
| public void writeRow(final int[] newrow) Same as writeRow(int[] newrow, int rown), but does not check row number | |
| writeRow | back to summary |
|---|---|
| public void writeRow(final int[] newrow, final int rown) Alias to writeRowInt
| |
| writeRowByte | back to summary |
|---|---|
| public void writeRowByte(final byte[] newrow, final int rown) Same semantics as writeRowInt but using bytes. Each byte is still a sample. If 16bitdepth, we are passing only the most significant byte (and hence losing some info)
| |
| writeRowInt | back to summary |
|---|---|
| public void writeRowInt(final int[] newrow, final int rown) Writes a full image row. This must be called sequentially from n=0 to n=rows-1 One integer per sample , in the natural order: R G B R G B ... (or R G B A R G B A... if has alpha) The values should be between 0 and 255 for 8 bitspc images, and between 0- 65535 form 16 bitspc images (this applies also to the alpha channel if present) The array can be reused. Warning the array might be modified in some cases (unpacked row with low bitdepth)
| |
| writeRowsByte | back to summary |
|---|---|
| public void writeRowsByte(final byte[][] image) Writes all the pixels, calling writeRowByte() for each image row | |
| writeRowsInt | back to summary |
|---|---|
| public void writeRowsInt(final int[][] image) Writes all the pixels, calling writeRowInt() for each image row | |
| writeSignatureAndIHDR | back to summary |
|---|---|
| private void writeSignatureAndIHDR() Write id signature and also "IHDR" chunk | |