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
DecoderOptionsstream
Stream
Returns
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
DecoderOptionsThe general decoder options.
stream
StreamThe Stream containing image data.
cancellationToken
CancellationTokenThe token to monitor for cancellation requests.
Returns
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
DecoderOptionsstream
StreamcancellationToken
CancellationToken
Returns
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
DecoderOptionsstream
StreamcancellationToken
CancellationToken
Returns
Type Parameters
TPixel
Decode<TPixel>(DecoderOptions, Stream)
public Image<TPixel> Decode<TPixel>(DecoderOptions options, Stream stream) where TPixel : unmanaged, IPixel<TPixel>
Parameters
options
DecoderOptionsstream
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
DecoderOptionsThe general decoder options.
stream
StreamThe Stream containing image data.
cancellationToken
CancellationTokenThe 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
DecoderOptionsstream
Stream
Returns
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
DecoderOptionsThe general decoder options.
stream
StreamThe Stream containing image data.
cancellationToken
CancellationTokenThe token to monitor for cancellation requests.
Returns
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
DecoderOptionsstream
StreamcancellationToken
CancellationToken
Returns
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
DecoderOptionsThe decoder options.
image
ImageThe decoded image.