C# Class Hjg.Pngcs.PngWriter

Writes a PNG image, line by line.
Afficher le fichier Open project: devedse/DeveMazeGenerator Class Usage Examples

Méthodes publiques

Свойство Type Description
ImgInfo Hjg.Pngcs.ImageInfo

Protected Properties

Свойство Type Description
filename String
rowb byte[]
rowbfilter byte[]
rowbprev byte[]

Méthodes publiques

Méthode Description
ComputeCompressionRatio ( ) : double

Computes compressed size/raw size, approximate

Actually: compressed size = total size of IDAT data , raw size = uncompressed pixel bytes = rows * (bytesPerRow + 1)

CopyChunksFirst ( PngReader reader, int copy_mask ) : void
CopyChunksLast ( PngReader reader, int copy_mask ) : void
End ( ) : void

Finalizes the image creation and closes the file stream.

This MUST be called after writing the lines.

GetChunksList ( ) : ChunksListForWrite
GetFilename ( ) : String

Filename or description, from the optional constructor argument.

GetMetadata ( ) : PngMetadata
IsUnpackedMode ( ) : bool
PngWriter ( Stream outputStream, Hjg.Pngcs.ImageInfo imgInfo ) : System

Constructs a PngWriter from a outputStream, with no filename information

PngWriter ( Stream outputStream, Hjg.Pngcs.ImageInfo imgInfo, String filename ) : System

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()

SetFilterType ( FilterType filterType ) : void

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

SetUseUnPackedMode ( bool useUnpackedMode ) : void
WriteRow ( Hjg.Pngcs.ImageLine imgline, int rownumber ) : void

this uses the row number from the imageline!

WriteRow ( int newrow ) : void
WriteRow ( int newrow, int rown ) : void
WriteRowByte ( byte newrow, int rown ) : void
WriteRowInt ( int newrow, int rown ) : void

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.

WriteRowsByte ( byte image ) : void
WriteRowsInt ( int image ) : void

Méthodes protégées

Méthode Description
encodeRowFromByte ( byte row ) : void
encodeRowFromInt ( int row ) : void

Private Methods

Méthode Description
CopyChunks ( PngReader reader, int copy_mask, bool onlyAfterIdat ) : void

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

FilterRow ( int rown ) : void
FilterRowAverage ( ) : void
FilterRowNone ( ) : void
FilterRowPaeth ( ) : void
FilterRowSub ( ) : void
FilterRowUp ( ) : void
SumRowbfilter ( ) : long
WriteEndChunk ( ) : void
WriteFirstChunks ( ) : void
WriteLastChunks ( ) : void
WriteSignatureAndIHDR ( ) : void

Write id signature and also "IHDR" chunk

filterAndSend ( int rown ) : void
init ( ) : void

init: is called automatically before writing the first row

prepareEncodeRow ( int rown ) : void
reportResultsForFilter ( int rown, FilterType type, bool tentative ) : void

Method Details

ComputeCompressionRatio() public méthode

Computes compressed size/raw size, approximate
Actually: compressed size = total size of IDAT data , raw size = uncompressed pixel bytes = rows * (bytesPerRow + 1)
public ComputeCompressionRatio ( ) : double
Résultat double

CopyChunksFirst() public méthode

public CopyChunksFirst ( PngReader reader, int copy_mask ) : void
reader PngReader
copy_mask int
Résultat void

CopyChunksLast() public méthode

public CopyChunksLast ( PngReader reader, int copy_mask ) : void
reader PngReader
copy_mask int
Résultat void

End() public méthode

Finalizes the image creation and closes the file stream.
This MUST be called after writing the lines.
public End ( ) : void
Résultat void

GetChunksList() public méthode

public GetChunksList ( ) : ChunksListForWrite
Résultat ChunksListForWrite

GetFilename() public méthode

Filename or description, from the optional constructor argument.
public GetFilename ( ) : String
Résultat String

GetMetadata() public méthode

public GetMetadata ( ) : PngMetadata
Résultat PngMetadata

IsUnpackedMode() public méthode

public IsUnpackedMode ( ) : bool
Résultat bool

PngWriter() public méthode

Constructs a PngWriter from a outputStream, with no filename information
public PngWriter ( Stream outputStream, Hjg.Pngcs.ImageInfo imgInfo ) : System
outputStream Stream
imgInfo Hjg.Pngcs.ImageInfo
Résultat System

PngWriter() public méthode

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()
public PngWriter ( Stream outputStream, Hjg.Pngcs.ImageInfo imgInfo, String filename ) : System
outputStream Stream Opened stream for binary writing
imgInfo Hjg.Pngcs.ImageInfo Basic image parameters
filename String Optional, can be the filename or a description.
Résultat System

SetFilterType() public méthode

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
public SetFilterType ( FilterType filterType ) : void
filterType FilterType One of the five prediction types or strategy to choose it
Résultat void

SetUseUnPackedMode() public méthode

public SetUseUnPackedMode ( bool useUnpackedMode ) : void
useUnpackedMode bool
Résultat void

WriteRow() public méthode

this uses the row number from the imageline!
public WriteRow ( Hjg.Pngcs.ImageLine imgline, int rownumber ) : void
imgline Hjg.Pngcs.ImageLine
rownumber int
Résultat void

WriteRow() public méthode

public WriteRow ( int newrow ) : void
newrow int
Résultat void

WriteRow() public méthode

public WriteRow ( int newrow, int rown ) : void
newrow int
rown int
Résultat void

WriteRowByte() public méthode

public WriteRowByte ( byte newrow, int rown ) : void
newrow byte
rown int
Résultat void

WriteRowInt() public méthode

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.
public WriteRowInt ( int newrow, int rown ) : void
newrow int Array of pixel values
rown int Number of row, from 0 (top) to rows-1 (bottom)
Résultat void

WriteRowsByte() public méthode

public WriteRowsByte ( byte image ) : void
image byte
Résultat void

WriteRowsInt() public méthode

public WriteRowsInt ( int image ) : void
image int
Résultat void

encodeRowFromByte() protected méthode

protected encodeRowFromByte ( byte row ) : void
row byte
Résultat void

encodeRowFromInt() protected méthode

protected encodeRowFromInt ( int row ) : void
row int
Résultat void

Property Details

ImgInfo public_oe property

Basic image info, inmutable
public ImageInfo,Hjg.Pngcs ImgInfo
Résultat Hjg.Pngcs.ImageInfo

filename protected_oe property

filename, or description - merely informative, can be empty
protected String filename
Résultat String

rowb protected_oe property

raw current row, as array of bytes,counting from 1 (index 0 is reserved for filter type)
protected byte[] rowb
Résultat byte[]

rowbfilter protected_oe property

raw current row, after filtered
protected byte[] rowbfilter
Résultat byte[]

rowbprev protected_oe property

previuos raw row
protected byte[] rowbprev
Résultat byte[]