Table of Contents

Class ImageDecoder

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

Acts as a base class for image decoders. Types that inherit this decoder are required to implement cancellable synchronous decoding operations only.

public abstract class ImageDecoder : IImageDecoder
Inheritance
ImageDecoder
Implements
Derived
Inherited Members

Constructors

ImageDecoder()

protected ImageDecoder()

Methods

Decode(DecoderOptions, Stream)

public Image Decode(DecoderOptions options, Stream stream)

Parameters

options DecoderOptions
stream Stream

Returns

Image

Decode(DecoderOptions, Stream, CancellationToken)

Decodes the image from the specified stream to an Image.

protected abstract Image Decode(DecoderOptions options, Stream stream, CancellationToken cancellationToken)

Parameters

options DecoderOptions

The general decoder options.

stream Stream

The Stream containing image data.

cancellationToken CancellationToken

The token to monitor for cancellation requests.

Returns

Image

The Image.

Remarks

This method is designed to support the ImageSharp internal infrastructure and is not recommended for direct use.

Exceptions

ImageFormatException

Thrown if the encoded image contains errors.

DecodeAsync(DecoderOptions, Stream, CancellationToken)

public Task<Image> DecodeAsync(DecoderOptions options, Stream stream, CancellationToken cancellationToken = default)

Parameters

options DecoderOptions
stream Stream
cancellationToken CancellationToken

Returns

Task<Image>

DecodeAsync<TPixel>(DecoderOptions, Stream, CancellationToken)

public Task<Image<TPixel>> DecodeAsync<TPixel>(DecoderOptions options, Stream stream, CancellationToken cancellationToken = default) where TPixel : unmanaged, IPixel<TPixel>

Parameters

options DecoderOptions
stream Stream
cancellationToken CancellationToken

Returns

Task<Image<TPixel>>

Type Parameters

TPixel

Decode<TPixel>(DecoderOptions, Stream)

public Image<TPixel> Decode<TPixel>(DecoderOptions options, Stream stream) where TPixel : unmanaged, IPixel<TPixel>

Parameters

options DecoderOptions
stream Stream

Returns

Image<TPixel>

Type Parameters

TPixel

Decode<TPixel>(DecoderOptions, Stream, CancellationToken)

Decodes the image from the specified stream to an Image<TPixel> of a specific pixel type.

protected abstract Image<TPixel> Decode<TPixel>(DecoderOptions options, Stream stream, CancellationToken cancellationToken) where TPixel : unmanaged, IPixel<TPixel>

Parameters

options DecoderOptions

The general decoder options.

stream Stream

The Stream containing image data.

cancellationToken CancellationToken

The token to monitor for cancellation requests.

Returns

Image<TPixel>

The Image<TPixel>.

Type Parameters

TPixel

The pixel format.

Remarks

This method is designed to support the ImageSharp internal infrastructure and is not recommended for direct use.

Exceptions

ImageFormatException

Thrown if the encoded image contains errors.

Identify(DecoderOptions, Stream)

public ImageInfo Identify(DecoderOptions options, Stream stream)

Parameters

options DecoderOptions
stream Stream

Returns

ImageInfo

Identify(DecoderOptions, Stream, CancellationToken)

Reads the raw image information from the specified stream.

protected abstract ImageInfo Identify(DecoderOptions options, Stream stream, CancellationToken cancellationToken)

Parameters

options DecoderOptions

The general decoder options.

stream Stream

The Stream containing image data.

cancellationToken CancellationToken

The token to monitor for cancellation requests.

Returns

ImageInfo

The ImageInfo object.

Remarks

This method is designed to support the ImageSharp internal infrastructure and is not recommended for direct use.

Exceptions

ImageFormatException

Thrown if the encoded image contains errors.

IdentifyAsync(DecoderOptions, Stream, CancellationToken)

public Task<ImageInfo> IdentifyAsync(DecoderOptions options, Stream stream, CancellationToken cancellationToken = default)

Parameters

options DecoderOptions
stream Stream
cancellationToken CancellationToken

Returns

Task<ImageInfo>

ScaleToTargetSize(DecoderOptions, Image)

Performs a scaling operation against the decoded image. If the target size is not set, or the image size already matches the target size, the image is untouched.

protected static void ScaleToTargetSize(DecoderOptions options, Image image)

Parameters

options DecoderOptions

The decoder options.

image Image

The decoded image.