Table of Contents

Class BmpEncoder

Namespace
SixLabors.ImageSharp.Formats.Bmp
Assembly
SixLabors.ImageSharp.dll

Image encoder for writing an image to a stream as a Windows bitmap.

public sealed class BmpEncoder : QuantizingImageEncoder, IImageEncoder
Inheritance
BmpEncoder
Implements
Inherited Members

Constructors

BmpEncoder()

Initializes a new instance of the BmpEncoder class.

public BmpEncoder()

Properties

BitsPerPixel

Gets the number of bits per pixel.

public BmpBitsPerPixel? BitsPerPixel { get; init; }

Property Value

BmpBitsPerPixel?

SupportTransparency

Gets a value indicating whether the encoder should support transparency. Note: Transparency support only works together with 32 bits per pixel. This option will change the default behavior of the encoder of writing a bitmap version 3 info header with no compression. Instead a bitmap version 4 info header will be written with the BITFIELDS compression.

public bool SupportTransparency { get; init; }

Property Value

bool

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 Stream

The Stream to encode the image data to.

cancellationToken CancellationToken

The 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.