Class PngEncoder
Image encoder for writing image data to a stream in png format.
Implements
Inherited Members
Namespace: SixLabors.ImageSharp.Formats.Png
Assembly: SixLabors.ImageSharp.dll
Syntax
public class PngEncoder : QuantizingImageEncoder, IImageEncoder
Properties
BitDepth
Gets the number of bits per sample or per palette index (not per pixel). Not all values are allowed for all ColorType values.
Declaration
public PngBitDepth? BitDepth { get; init; }
Property Value
| Type | Description |
|---|---|
| PngBitDepth? |
ChunkFilter
Gets the chunk filter method. This allows to filter ancillary chunks.
Declaration
public PngChunkFilter? ChunkFilter { get; init; }
Property Value
| Type | Description |
|---|---|
| PngChunkFilter? |
ColorType
Gets the color type.
Declaration
public PngColorType? ColorType { get; init; }
Property Value
| Type | Description |
|---|---|
| PngColorType? |
CompressionLevel
Gets the compression level 1-9.
Declaration
public PngCompressionLevel CompressionLevel { get; init; }
Property Value
| Type | Description |
|---|---|
| PngCompressionLevel |
FilterMethod
Gets the filter method.
Declaration
public PngFilterMethod? FilterMethod { get; init; }
Property Value
| Type | Description |
|---|---|
| PngFilterMethod? |
Gamma
Gets the gamma value, that will be written the image.
Declaration
public float? Gamma { get; init; }
Property Value
| Type | Description |
|---|---|
| float? | The gamma value of the image. |
InterlaceMethod
Gets a value indicating whether this instance should write an Adam7 interlaced image.
Declaration
public PngInterlaceMode? InterlaceMethod { get; init; }
Property Value
| Type | Description |
|---|---|
| PngInterlaceMode? |
TextCompressionThreshold
Gets the threshold of characters in text metadata, when compression should be used.
Declaration
public int TextCompressionThreshold { get; init; }
Property Value
| Type | Description |
|---|---|
| int |
Threshold
Gets the transparency threshold.
Declaration
public byte Threshold { get; init; }
Property Value
| Type | Description |
|---|---|
| byte |
TransparentColorMode
Gets a value indicating whether fully transparent pixels that may contain R, G, B values which are not 0, should be converted to transparent black, which can yield in better compression in some cases.
Declaration
public PngTransparentColorMode TransparentColorMode { get; init; }
Property Value
| Type | Description |
|---|---|
| PngTransparentColorMode |
Methods
Encode<TPixel>(Image<TPixel>, Stream, CancellationToken)
Encodes the image to the specified stream from the Image<TPixel>.
Declaration
protected override void Encode<TPixel>(Image<TPixel> image, Stream stream, CancellationToken cancellationToken) where TPixel : unmanaged, IPixel<TPixel>
Parameters
| Type | Name | Description |
|---|---|---|
| Image<TPixel> | image | The Image<TPixel> to encode from. |
| Stream | stream | The Stream to encode the image data to. |
| CancellationToken | cancellationToken | The token to monitor for cancellation requests. |
Type Parameters
| Name | Description |
|---|---|
| TPixel | The pixel format. |
Overrides
Remarks
This method is designed to support the ImageSharp internal infrastructure and is not recommended for direct use.