PngCs
1.1.4
A C# library for read/write PNG images
|
Reads a PNG image, line by line More...
Public Member Functions | |
PngReader (Stream inputStream) | |
Constructs a PngReader from a Stream, with no filename information | |
PngReader (Stream inputStream, String filename) | |
Constructs a PNGReader objet from a opened Stream | |
ChunksList | GetChunksList () |
Returns the ancillary chunks available | |
PngMetadata | GetMetadata () |
Returns the ancillary chunks available | |
ImageLine | ReadRow (int nrow) |
reads the row using ImageLine as buffer | |
ImageLine | ReadRowInt (int nrow) |
ImageLine | ReadRowByte (int nrow) |
int[] | ReadRow (int[] buffer, int nrow) |
int[] | ReadRowInt (int[] buffer, int nrow) |
byte[] | ReadRowByte (byte[] buffer, int nrow) |
ImageLine | GetRow (int nrow) |
| |
ImageLines | ReadRowsInt (int rowOffset, int nRows, int rowStep) |
ImageLines | ReadRowsInt () |
ImageLines | ReadRowsByte (int rowOffset, int nRows, int rowStep) |
ImageLines | ReadRowsByte () |
void | ReadSkippingAllRows () |
override String | ToString () |
void | End () |
Normally this does nothing, but it can be used to force a premature closing | |
bool | IsInterlaced () |
void | SetUnpackedMode (bool unPackedMode) |
bool | IsUnpackedMode () |
void | SetCrcCheckDisabled () |
Public Attributes | |
readonly bool | interlaced |
Protected Attributes | |
readonly String | filename |
filename, or description - merely informative, can be empty | |
ImageLine | imgLine |
buffer: last read line | |
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 unfiltered | |
int | rowNum = -1 |
last read row number | |
Adler32 | crctest |
Properties | |
ImageInfo | ImgInfo [get, set] |
Basic image info, inmutable | |
ChunkLoadBehaviour | ChunkLoadBehaviour [get, set] |
Strategy for chunk loading. Default: LOAD_CHUNK_ALWAYS | |
bool | ShouldCloseStream [get, set] |
Should close the underlying Input Stream when ends? | |
long | MaxBytesMetadata [get, set] |
Maximum amount of bytes from ancillary chunks to load in memory | |
long | MaxTotalBytesRead [get, set] |
Maximum total bytes to read from stream | |
int | SkipChunkMaxSize [get, set] |
Maximum ancillary chunk size | |
String[] | SkipChunkIds [get, set] |
Ancillary chunks to skip | |
int | CurrentChunkGroup [get, set] |
number of chunk group (0-6) last read, or currently reading | |
Reads a PNG image, line by line
The typical reading sequence is as follows:
1. At construction time, the header and IHDR chunk are read (basic image info)
2 (Optional) you can set some global options: UnpackedMode CrcCheckDisabled
3. (Optional) If you call GetMetadata() or or GetChunksLisk() before reading the pixels, the chunks before IDAT are automatically loaded and available
4a. The rows are read, one by one, with the ReadRowXXX
methods: (ReadRowInt() , ReadRowByte(), etc) in order, from 0 to nrows-1 (you can skip or repeat rows, but not go backwards)
4b. Alternatively, you can read all rows, or a subset, in a single call: see ReadRowsInt(), ReadRowsByte() In general this consumes more memory, but for interlaced images this is equally efficient, and more so if reading a small subset of rows.
5. Read of the last row automatically loads the trailing chunks, and ends the reader.
6. End() forcibly finishes/aborts the reading and closes the stream
Hjg.Pngcs.PngReader.PngReader | ( | Stream | inputStream | ) |
Constructs a PngReader from a Stream, with no filename information
inputStream |
Hjg.Pngcs.PngReader.PngReader | ( | Stream | inputStream, |
String | filename | ||
) |
Constructs a PNGReader objet from a opened Stream
The constructor reads the signature and first chunk (IDHR)
inputStream | |
filename | Optional, can be the filename or a description. |
ChunksList Hjg.Pngcs.PngReader.GetChunksList | ( | ) |
Returns the ancillary chunks available
If the rows have not yet still been read, this includes only the chunks placed before the pixels (IDAT)
PngMetadata Hjg.Pngcs.PngReader.GetMetadata | ( | ) |
Returns the ancillary chunks available
see GetChunksList
ImageLine Hjg.Pngcs.PngReader.ReadRow | ( | int | nrow | ) |
ImageLine Hjg.Pngcs.PngReader.ReadRowInt | ( | int | nrow | ) |
ImageLine Hjg.Pngcs.PngReader.ReadRowByte | ( | int | nrow | ) |
int [] Hjg.Pngcs.PngReader.ReadRow | ( | int[] | buffer, |
int | nrow | ||
) |
int [] Hjg.Pngcs.PngReader.ReadRowInt | ( | int[] | buffer, |
int | nrow | ||
) |
byte [] Hjg.Pngcs.PngReader.ReadRowByte | ( | byte[] | buffer, |
int | nrow | ||
) |
ImageLine Hjg.Pngcs.PngReader.GetRow | ( | int | nrow | ) |
nrow |
ImageLines Hjg.Pngcs.PngReader.ReadRowsInt | ( | int | rowOffset, |
int | nRows, | ||
int | rowStep | ||
) |
ImageLines Hjg.Pngcs.PngReader.ReadRowsInt | ( | ) |
ImageLines Hjg.Pngcs.PngReader.ReadRowsByte | ( | int | rowOffset, |
int | nRows, | ||
int | rowStep | ||
) |
ImageLines Hjg.Pngcs.PngReader.ReadRowsByte | ( | ) |
void Hjg.Pngcs.PngReader.ReadSkippingAllRows | ( | ) |
override String Hjg.Pngcs.PngReader.ToString | ( | ) |
void Hjg.Pngcs.PngReader.End | ( | ) |
Normally this does nothing, but it can be used to force a premature closing
bool Hjg.Pngcs.PngReader.IsInterlaced | ( | ) |
void Hjg.Pngcs.PngReader.SetUnpackedMode | ( | bool | unPackedMode | ) |
bool Hjg.Pngcs.PngReader.IsUnpackedMode | ( | ) |
void Hjg.Pngcs.PngReader.SetCrcCheckDisabled | ( | ) |
|
protected |
filename, or description - merely informative, can be empty
|
protected |
buffer: last read line
|
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 unfiltered
readonly bool Hjg.Pngcs.PngReader.interlaced |
|
protected |
last read row number
|
protected |
|
getset |
Basic image info, inmutable
|
getset |
Strategy for chunk loading. Default: LOAD_CHUNK_ALWAYS
|
getset |
Should close the underlying Input Stream when ends?
|
getset |
Maximum amount of bytes from ancillary chunks to load in memory
Default: 5MB. 0: unlimited. If exceeded, chunks will be skipped
|
getset |
Maximum total bytes to read from stream
Default: 200MB. 0: Unlimited. If exceeded, an exception will be thrown
|
getset |
Maximum ancillary chunk size
Default: 2MB, 0: unlimited. Chunks exceeding this size will be skipped (nor even CRC checked)
|
getset |
Ancillary chunks to skip
Default: { "fdAT" }. chunks with these ids will be skipped (nor even CRC checked)
|
getset |
number of chunk group (0-6) last read, or currently reading
see ChunksList.CHUNK_GROUP_NNN