|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectar.com.hjg.pngj.PngWriter
public class PngWriter
Writes a PNG image, line by line.
Field Summary | |
---|---|
ImageInfo |
imgInfo
|
Constructor Summary | |
---|---|
PngWriter(OutputStream outputStream,
ImageInfo imgInfo)
|
|
PngWriter(OutputStream outputStream,
ImageInfo imgInfo,
String filenameOrDescription)
Constructs a new PngWriter from a output stream. |
Method Summary | |
---|---|
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() |
void |
copyChunksFirst(PngReader reader,
int copy_mask)
Copies first (pre IDAT) ancillary chunks from a PngReader. |
void |
copyChunksLast(PngReader reader,
int copy_mask)
Copies last (post IDAT) ancillary chunks from a PngReader. |
void |
end()
Finalizes the image creation and closes the stream. |
ChunksListForWrite |
getChunkList()
|
String |
getFilename()
Filename or description, from the optional constructor argument. |
PngMetadata |
getMetadata()
|
void |
setCompLevel(int compLevel)
Sets compression level of ZIP algorithm. |
void |
setDeflaterStrategy(int deflaterStrategy)
|
void |
setFilterType(FilterType filterType)
Sets internal prediction filter type, or strategy to choose it. |
void |
setIdatMaxSize(int idatMaxSize)
Sets maximum size of IDAT fragments. |
void |
setShouldCloseStream(boolean shouldCloseStream)
if true, input stream will be closed after ending write default=true |
void |
writeRow(ImageLine imgline,
int rownumber)
Writes line. |
void |
writeRow(int[] newrow)
Same as writeRow(int[] newrow, int rown), but does not check row number |
void |
writeRow(int[] newrow,
int rown)
Writes a full image row. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public final ImageInfo imgInfo
Constructor Detail |
---|
public PngWriter(OutputStream outputStream, ImageInfo imgInfo)
public PngWriter(OutputStream outputStream, ImageInfo imgInfo, String filenameOrDescription)
See also FileHelper.createPngWriter()
if available.
outputStream
- Opened stream for binary writingimgInfo
- Basic image parametersfilenameOrDescription
- Optional, just for error/debug messagesMethod Detail |
---|
public double computeCompressionRatio()
public void copyChunksFirst(PngReader reader, int copy_mask)
Should be called when creating an image from another, before starting writing lines, to copy relevant chunks.
reader
- : PngReader object, already opened.copy_mask
- : Mask bit (OR), see ChunksToWrite.COPY_XXX
constantspublic void copyChunksLast(PngReader reader, int copy_mask)
Should be called when creating an image from another, after writing all lines, before closing the writer, to copy additional chunks.
reader
- : PngReader object, already opened and fully read.copy_mask
- : Mask bit (OR), see ChunksToWrite.COPY_XXX
constantspublic void end()
public ChunksListForWrite getChunkList()
public String getFilename()
public PngMetadata getMetadata()
public void setCompLevel(int compLevel)
This must be called just after constructor, before starting writing.
See also setFilterType()
compLevel
- between 0 and 9 (default:6 , recommended: 6 or more)public void setDeflaterStrategy(int deflaterStrategy)
public void setFilterType(FilterType filterType)
This must be called just after constructor, before starting writing.
See also setCompLevel()
filterType
- One of the five prediction types or strategy to choose it (see PngFilterType
) Recommended
values: DEFAULT (default) or AGGRESIVEpublic void setIdatMaxSize(int idatMaxSize)
idatMaxSize
- default=0 : use defaultSize (32K)public void setShouldCloseStream(boolean shouldCloseStream)
default=true
public void writeRow(ImageLine imgline, int rownumber)
public void writeRow(int[] newrow)
newrow
- public void writeRow(int[] newrow, int rown)
newrow
- Array of pixel valuesrown
- Row number, from 0 (top) to rows-1 (bottom). This is just used as a check. Pass -1 if you want to
autocompute it
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |