C# Класс Hjg.Pngcs.PngWriter

Writes a PNG image, line by line.
Показать файл Открыть проект Примеры использования класса

Открытые свойства

Свойство Тип Описание
ImgInfo Hjg.Pngcs.ImageInfo

Защищенные свойства (Protected)

Свойство Тип Описание
filename String
rowb byte[]
rowbfilter byte[]
rowbprev byte[]

Открытые методы

Метод Описание
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

Защищенные методы

Метод Описание
encodeRowFromByte ( byte row ) : void
encodeRowFromInt ( int row ) : void

Приватные методы

Метод Описание
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

Описание методов

ComputeCompressionRatio() публичный Метод

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
Результат double

CopyChunksFirst() публичный Метод

public CopyChunksFirst ( PngReader reader, int copy_mask ) : void
reader PngReader
copy_mask int
Результат void

CopyChunksLast() публичный Метод

public CopyChunksLast ( PngReader reader, int copy_mask ) : void
reader PngReader
copy_mask int
Результат void

End() публичный Метод

Finalizes the image creation and closes the file stream.
This MUST be called after writing the lines.
public End ( ) : void
Результат void

GetChunksList() публичный Метод

public GetChunksList ( ) : ChunksListForWrite
Результат ChunksListForWrite

GetFilename() публичный Метод

Filename or description, from the optional constructor argument.
public GetFilename ( ) : String
Результат String

GetMetadata() публичный Метод

public GetMetadata ( ) : PngMetadata
Результат PngMetadata

IsUnpackedMode() публичный Метод

public IsUnpackedMode ( ) : bool
Результат bool

PngWriter() публичный Метод

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
Результат System

PngWriter() публичный Метод

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.
Результат System

SetFilterType() публичный Метод

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
Результат void

SetUseUnPackedMode() публичный Метод

public SetUseUnPackedMode ( bool useUnpackedMode ) : void
useUnpackedMode bool
Результат void

WriteRow() публичный Метод

this uses the row number from the imageline!
public WriteRow ( Hjg.Pngcs.ImageLine imgline, int rownumber ) : void
imgline Hjg.Pngcs.ImageLine
rownumber int
Результат void

WriteRow() публичный Метод

public WriteRow ( int newrow ) : void
newrow int
Результат void

WriteRow() публичный Метод

public WriteRow ( int newrow, int rown ) : void
newrow int
rown int
Результат void

WriteRowByte() публичный Метод

public WriteRowByte ( byte newrow, int rown ) : void
newrow byte
rown int
Результат void

WriteRowInt() публичный Метод

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)
Результат void

WriteRowsByte() публичный Метод

public WriteRowsByte ( byte image ) : void
image byte
Результат void

WriteRowsInt() публичный Метод

public WriteRowsInt ( int image ) : void
image int
Результат void

encodeRowFromByte() защищенный Метод

protected encodeRowFromByte ( byte row ) : void
row byte
Результат void

encodeRowFromInt() защищенный Метод

protected encodeRowFromInt ( int row ) : void
row int
Результат void

Описание свойств

ImgInfo публичное свойство

Basic image info, inmutable
public ImageInfo,Hjg.Pngcs ImgInfo
Результат Hjg.Pngcs.ImageInfo

filename защищенное свойство

filename, or description - merely informative, can be empty
protected String filename
Результат String

rowb защищенное свойство

raw current row, as array of bytes,counting from 1 (index 0 is reserved for filter type)
protected byte[] rowb
Результат byte[]

rowbfilter защищенное свойство

raw current row, after filtered
protected byte[] rowbfilter
Результат byte[]

rowbprev защищенное свойство

previuos raw row
protected byte[] rowbprev
Результат byte[]