Class ImageDecoder
Acts as a base class for image decoders. Types that inherit this decoder are required to implement cancellable synchronous decoding operations only.
Inheritance
Implements
Inherited Members
Namespace: SixLabors.ImageSharp.Formats
Assembly: SixLabors.ImageSharp.dll
Syntax
public abstract class ImageDecoder : IImageDecoder
Methods
| Edit this page View SourceDecode(DecoderOptions, Stream)
Decodes the image from the specified stream to an Image of a specific pixel type.
Declaration
public Image Decode(DecoderOptions options, Stream stream)
Parameters
Type | Name | Description |
---|---|---|
DecoderOptions | options | The general decoder options. |
Stream | stream | The Stream containing image data. |
Returns
Type | Description |
---|---|
Image | The Image<TPixel>. |
Exceptions
Type | Condition |
---|---|
ImageFormatException | Thrown if the encoded image contains errors. |
Decode(DecoderOptions, Stream, CancellationToken)
Decodes the image from the specified stream to an Image.
Declaration
protected abstract Image Decode(DecoderOptions options, Stream stream, CancellationToken cancellationToken)
Parameters
Type | Name | Description |
---|---|---|
DecoderOptions | options | The general decoder options. |
Stream | stream | The Stream containing image data. |
CancellationToken | cancellationToken | The token to monitor for cancellation requests. |
Returns
Type | Description |
---|---|
Image | The Image. |
Remarks
This method is designed to support the ImageSharp internal infrastructure and is not recommended for direct use.
Exceptions
Type | Condition |
---|---|
ImageFormatException | Thrown if the encoded image contains errors. |
DecodeAsync(DecoderOptions, Stream, CancellationToken)
Decodes the image from the specified stream to an Image of a specific pixel type.
Declaration
public Task<Image> DecodeAsync(DecoderOptions options, Stream stream, CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
DecoderOptions | options | The general decoder options. |
Stream | stream | The Stream containing image data. |
CancellationToken | cancellationToken | The token to monitor for cancellation requests. |
Returns
Type | Description |
---|---|
Task<Image> | A Task<TResult> representing the asynchronous operation. |
Exceptions
Type | Condition |
---|---|
ImageFormatException | Thrown if the encoded image contains errors. |
DecodeAsync<TPixel>(DecoderOptions, Stream, CancellationToken)
Decodes the image from the specified stream to an Image<TPixel> of a specific pixel type.
Declaration
public Task<Image<TPixel>> DecodeAsync<TPixel>(DecoderOptions options, Stream stream, CancellationToken cancellationToken = default) where TPixel : unmanaged, IPixel<TPixel>
Parameters
Type | Name | Description |
---|---|---|
DecoderOptions | options | The general decoder options. |
Stream | stream | The Stream containing image data. |
CancellationToken | cancellationToken | The token to monitor for cancellation requests. |
Returns
Type | Description |
---|---|
Task<Image<TPixel>> | A Task<TResult> representing the asynchronous operation. |
Type Parameters
Name | Description |
---|---|
TPixel | The pixel format. |
Exceptions
Type | Condition |
---|---|
ImageFormatException | Thrown if the encoded image contains errors. |
Decode<TPixel>(DecoderOptions, Stream)
Decodes the image from the specified stream to an Image<TPixel> of a specific pixel type.
Declaration
public Image<TPixel> Decode<TPixel>(DecoderOptions options, Stream stream) where TPixel : unmanaged, IPixel<TPixel>
Parameters
Type | Name | Description |
---|---|---|
DecoderOptions | options | The general decoder options. |
Stream | stream | The Stream containing image data. |
Returns
Type | Description |
---|---|
Image<TPixel> | The Image<TPixel>. |
Type Parameters
Name | Description |
---|---|
TPixel | The pixel format. |
Exceptions
Type | Condition |
---|---|
ImageFormatException | Thrown if the encoded image contains errors. |
Decode<TPixel>(DecoderOptions, Stream, CancellationToken)
Decodes the image from the specified stream to an Image<TPixel> of a specific pixel type.
Declaration
protected abstract Image<TPixel> Decode<TPixel>(DecoderOptions options, Stream stream, CancellationToken cancellationToken) where TPixel : unmanaged, IPixel<TPixel>
Parameters
Type | Name | Description |
---|---|---|
DecoderOptions | options | The general decoder options. |
Stream | stream | The Stream containing image data. |
CancellationToken | cancellationToken | The token to monitor for cancellation requests. |
Returns
Type | Description |
---|---|
Image<TPixel> | The Image<TPixel>. |
Type Parameters
Name | Description |
---|---|
TPixel | The pixel format. |
Remarks
This method is designed to support the ImageSharp internal infrastructure and is not recommended for direct use.
Exceptions
Type | Condition |
---|---|
ImageFormatException | Thrown if the encoded image contains errors. |
Identify(DecoderOptions, Stream)
Reads the raw image information from the specified stream.
Declaration
public ImageInfo Identify(DecoderOptions options, Stream stream)
Parameters
Type | Name | Description |
---|---|---|
DecoderOptions | options | The general decoder options. |
Stream | stream | The Stream containing image data. |
Returns
Type | Description |
---|---|
ImageInfo | The ImageInfo object. |
Exceptions
Type | Condition |
---|---|
ImageFormatException | Thrown if the encoded image contains errors. |
Identify(DecoderOptions, Stream, CancellationToken)
Reads the raw image information from the specified stream.
Declaration
protected abstract ImageInfo Identify(DecoderOptions options, Stream stream, CancellationToken cancellationToken)
Parameters
Type | Name | Description |
---|---|---|
DecoderOptions | options | The general decoder options. |
Stream | stream | The Stream containing image data. |
CancellationToken | cancellationToken | The token to monitor for cancellation requests. |
Returns
Type | Description |
---|---|
ImageInfo | The ImageInfo object. |
Remarks
This method is designed to support the ImageSharp internal infrastructure and is not recommended for direct use.
Exceptions
Type | Condition |
---|---|
ImageFormatException | Thrown if the encoded image contains errors. |
IdentifyAsync(DecoderOptions, Stream, CancellationToken)
Reads the raw image information from the specified stream.
Declaration
public Task<ImageInfo> IdentifyAsync(DecoderOptions options, Stream stream, CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
DecoderOptions | options | The general decoder options. |
Stream | stream | The Stream containing image data. |
CancellationToken | cancellationToken | The token to monitor for cancellation requests. |
Returns
Type | Description |
---|---|
Task<ImageInfo> | The Task<TResult> object. |
Exceptions
Type | Condition |
---|---|
ImageFormatException | Thrown if the encoded image contains errors. |
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.
Declaration
protected static void ScaleToTargetSize(DecoderOptions options, Image image)
Parameters
Type | Name | Description |
---|---|---|
DecoderOptions | options | The decoder options. |
Image | image | The decoded image. |