PngCs
1.1.4
A C# library for read/write PNG images
|
Writes a PNG image, line by line. More...
Public Member Functions | |
PngWriter (Stream outputStream, ImageInfo imgInfo) | |
Constructs a PngWriter from a outputStream, with no filename information | |
PngWriter (Stream outputStream, ImageInfo imgInfo, String filename) | |
Constructs a PngWriter from a outputStream, with optional filename or description | |
void | CopyChunksFirst (PngReader reader, int copy_mask) |
void | CopyChunksLast (PngReader reader, int copy_mask) |
double | ComputeCompressionRatio () |
Computes compressed size/raw size, approximate | |
void | End () |
Finalizes the image creation and closes the file stream. | |
String | GetFilename () |
Filename or description, from the optional constructor argument. | |
void | WriteRow (ImageLine imgline, int rownumber) |
this uses the row number from the imageline! | |
void | WriteRow (int[] newrow) |
void | WriteRow (int[] newrow, int rown) |
void | WriteRowInt (int[] newrow, int rown) |
Writes a full image row. | |
void | WriteRowByte (byte[] newrow, int rown) |
void | WriteRowsInt (int[][] image) |
void | WriteRowsByte (byte[][] image) |
PngMetadata | GetMetadata () |
ChunksListForWrite | GetChunksList () |
void | SetFilterType (FilterType filterType) |
Sets internal prediction filter type, or strategy to choose it. | |
bool | IsUnpackedMode () |
void | SetUseUnPackedMode (bool useUnpackedMode) |
Public Attributes | |
readonly ImageInfo | ImgInfo |
Basic image info, inmutable | |
Protected Member Functions | |
void | encodeRowFromByte (byte[] row) |
void | encodeRowFromInt (int[] row) |
Protected Attributes | |
readonly String | filename |
filename, or description - merely informative, can be empty | |
byte[] | rowb |
raw current row, as array of bytes,counting from 1 (index 0 is reserved for filter type) | |
byte[] | rowbprev |
previuos raw row | |
byte[] | rowbfilter |
raw current row, after filtered | |
Properties | |
EDeflateCompressStrategy | CompressionStrategy [get, set] |
int | CompLevel [get, set] |
zip compression level (0 - 9) | |
bool | ShouldCloseStream [get, set] |
true: closes stream after ending write | |
int | IdatMaxSize [get, set] |
Maximum size of IDAT chunks | |
int | CurrentChunkGroup [get, set] |
number of chunk group (0-6) last writen, or currently writing | |
Writes a PNG image, line by line.
Hjg.Pngcs.PngWriter.PngWriter | ( | Stream | outputStream, |
ImageInfo | imgInfo | ||
) |
Constructs a PngWriter from a outputStream, with no filename information
outputStream | |
imgInfo |
Hjg.Pngcs.PngWriter.PngWriter | ( | Stream | outputStream, |
ImageInfo | imgInfo, | ||
String | filename | ||
) |
Constructs a PngWriter from a outputStream, with optional filename or description
After construction nothing is writen yet. You still can set some parameters (compression, filters) and queue chunks before start writing the pixels.
See also FileHelper.createPngWriter()
outputStream | Opened stream for binary writing |
imgInfo | Basic image parameters |
filename | Optional, can be the filename or a description. |
|
protected |
|
protected |
void Hjg.Pngcs.PngWriter.CopyChunksFirst | ( | PngReader | reader, |
int | copy_mask | ||
) |
void Hjg.Pngcs.PngWriter.CopyChunksLast | ( | PngReader | reader, |
int | copy_mask | ||
) |
double Hjg.Pngcs.PngWriter.ComputeCompressionRatio | ( | ) |
Computes compressed size/raw size, approximate
Actually: compressed size = total size of IDAT data , raw size = uncompressed pixel bytes = rows * (bytesPerRow + 1)
void Hjg.Pngcs.PngWriter.End | ( | ) |
Finalizes the image creation and closes the file stream.
This MUST be called after writing the lines.
String Hjg.Pngcs.PngWriter.GetFilename | ( | ) |
Filename or description, from the optional constructor argument.
void Hjg.Pngcs.PngWriter.WriteRow | ( | ImageLine | imgline, |
int | rownumber | ||
) |
this uses the row number from the imageline!
void Hjg.Pngcs.PngWriter.WriteRow | ( | int[] | newrow | ) |
void Hjg.Pngcs.PngWriter.WriteRow | ( | int[] | newrow, |
int | rown | ||
) |
void Hjg.Pngcs.PngWriter.WriteRowInt | ( | int[] | newrow, |
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.
newrow | Array of pixel values |
rown | Number of row, from 0 (top) to rows-1 (bottom) |
void Hjg.Pngcs.PngWriter.WriteRowByte | ( | byte[] | newrow, |
int | rown | ||
) |
void Hjg.Pngcs.PngWriter.WriteRowsInt | ( | int | image[][] | ) |
Writes all the pixels, calling writeRowInt() for each image row
void Hjg.Pngcs.PngWriter.WriteRowsByte | ( | byte | image[][] | ) |
Writes all the pixels, calling writeRowByte() for each image row
PngMetadata Hjg.Pngcs.PngWriter.GetMetadata | ( | ) |
ChunksListForWrite Hjg.Pngcs.PngWriter.GetChunksList | ( | ) |
void Hjg.Pngcs.PngWriter.SetFilterType | ( | FilterType | filterType | ) |
Sets internal prediction filter type, or strategy to choose it.
This must be called just after constructor, before starting writing.
Recommended values: DEFAULT (default) or AGGRESIVE
filterType | One of the five prediction types or strategy to choose it |
bool Hjg.Pngcs.PngWriter.IsUnpackedMode | ( | ) |
void Hjg.Pngcs.PngWriter.SetUseUnPackedMode | ( | bool | useUnpackedMode | ) |
readonly ImageInfo Hjg.Pngcs.PngWriter.ImgInfo |
Basic image info, inmutable
|
protected |
filename, or description - merely informative, can be empty
|
protected |
raw current row, as array of bytes,counting from 1 (index 0 is reserved for filter type)
|
protected |
previuos raw row
|
protected |
raw current row, after filtered
|
getset |
Deflate algortithm compression strategy
|
getset |
zip compression level (0 - 9)
default:6
9 is the maximum compression
|
getset |
true: closes stream after ending write
|
getset |
Maximum size of IDAT chunks
0=use default (PngIDatChunkOutputStream 32768)
|
getset |
number of chunk group (0-6) last writen, or currently writing
see ChunksList.CHUNK_GROUP_NNN