Class PngEncoder
- Namespace
- SixLabors.ImageSharp.Formats.Png
- Assembly
- SixLabors.ImageSharp.dll
Image encoder for writing image data to a stream in png format.
public class PngEncoder : QuantizingImageEncoder, IImageEncoder
- Inheritance
-
PngEncoder
- Implements
- Inherited Members
Constructors
PngEncoder()
Initializes a new instance of the PngEncoder class.
public PngEncoder()
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.
public PngBitDepth? BitDepth { get; init; }
Property Value
ChunkFilter
Gets the chunk filter method. This allows to filter ancillary chunks.
public PngChunkFilter? ChunkFilter { get; init; }
Property Value
ColorType
Gets the color type.
public PngColorType? ColorType { get; init; }
Property Value
CompressionLevel
Gets the compression level 1-9.
public PngCompressionLevel CompressionLevel { get; init; }
Property Value
FilterMethod
Gets the filter method.
public PngFilterMethod? FilterMethod { get; init; }
Property Value
Gamma
Gets the gamma value, that will be written the image.
public float? Gamma { get; init; }
Property Value
- float?
The gamma value of the image.
InterlaceMethod
Gets a value indicating whether this instance should write an Adam7 interlaced image.
public PngInterlaceMode? InterlaceMethod { get; init; }
Property Value
TextCompressionThreshold
Gets the threshold of characters in text metadata, when compression should be used.
public int TextCompressionThreshold { get; init; }
Property Value
Threshold
Gets the transparency threshold.
public byte Threshold { get; init; }
Property Value
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.
public PngTransparentColorMode TransparentColorMode { get; init; }
Property Value
Methods
Encode<TPixel>(Image<TPixel>, Stream, CancellationToken)
Encodes the image to the specified stream from the Image<TPixel>.
protected override void Encode<TPixel>(Image<TPixel> image, Stream stream, CancellationToken cancellationToken) where TPixel : unmanaged, IPixel<TPixel>
Parameters
image
Image<TPixel>The Image<TPixel> to encode from.
stream
StreamThe Stream to encode the image data to.
cancellationToken
CancellationTokenThe token to monitor for cancellation requests.
Type Parameters
TPixel
The pixel format.
Remarks
This method is designed to support the ImageSharp internal infrastructure and is not recommended for direct use.