CustomImageDecodeContext Class

The context of one call to CustomImageCodec.Decode or CustomImageCodec.Identify: the configuration and the request of the operation, and the factory of the decoded images.

public sealed class CustomImageDecodeContext

Remarks

The context is only valid during the call that received it. The images it created and the codec does not return are disposed when the call returns, and all of them when it throws.

Properties

NameDescription
CancellationTokenGets the token of the operation. Check it between rows or frames of a long decode.
ConfigurationGets the configuration of the operation: its resource limits and its parallelism.
FrameLimitGets the maximum number of displayed frames the load keeps (ImageDecodeOptions.FrameLimit), or null for all of them. The library removes the frames beyond it: a codec may stop decoding there.
IdentifyModeGets the mode of an identification, or null when the call decodes the image.
RequestedPixelFormatGets the pixel format of a typed load (Image.Load), or null. The library converts the decoded image when its format differs: a codec may produce this format directly to save the conversion.

Gets the token of the operation. Check it between rows or frames of a long decode.

public CancellationToken CancellationToken { get; }

Property value

CancellationToken

Gets the configuration of the operation: its resource limits and its parallelism.

public ImageConfiguration Configuration { get; }

Property value

ImageConfiguration

Gets the maximum number of displayed frames the load keeps (ImageDecodeOptions.FrameLimit), or null for all of them. The library removes the frames beyond it: a codec may stop decoding there.

public int? FrameLimit { get; }

Property value

int?

Gets the mode of an identification, or null when the call decodes the image.

public ImageIdentifyMode? IdentifyMode { get; }

Property value

ImageIdentifyMode?

RequestedPixelFormat

CustomImageDecodeContext.cs

Gets the pixel format of a typed load (Image.Load), or null. The library converts the decoded image when its format differs: a codec may produce this format directly to save the conversion.

public PixelFormat? RequestedPixelFormat { get; }

Property value

PixelFormat?

Methods

NameDescription
CreateImage(PixelFormat, int, int)Creates a single-frame still image of a pixel format whose pixels are all zero, charged to the operation.
CreateImage<TPixel>(int, int)Creates a single-frame still image whose pixels are all zero, charged to the operation.

CreateImage overloads

CreateImage(PixelFormat, int, int)

CustomImageDecodeContext.cs

Creates a single-frame still image of a pixel format whose pixels are all zero, charged to the operation.

public Image CreateImage(PixelFormat pixelFormat, int width, int height)
Parameters
pixelFormat PixelFormat
The pixel format.
width int
The width. Must be positive.
height int
The height. Must be positive.
Returns

Image The image, an Image<TPixel> of the pixel type of pixelFormat.

Exceptions
ArgumentOutOfRangeException
pixelFormat is not defined, or width or height is not positive.
ImageResourceLimitException
The image exceeds a limit of CustomImageDecodeContext.Configuration.
InvalidOperationException
The call that received the context has returned.
Remarks

The image has the configuration of the operation, and its pixels count toward the ImageResourceLimits.MaxLiveAllocationBytes budget of the load. An image of a floating-point pixel format is labeled as linear light (ColorTransferFunction.Linear), like a new image.

CreateImage<TPixel>(int, int)

CustomImageDecodeContext.cs

Creates a single-frame still image whose pixels are all zero, charged to the operation.

public Image<TPixel> CreateImage<TPixel>(int width, int height) where TPixel : unmanaged
Type parameters
TPixel
The pixel type.
Parameters
width int
The width. Must be positive.
height int
The height. Must be positive.
Returns

Image<TPixel> The image. Add frames with Image<TPixel>.AppendFrame.

Exceptions
NotSupportedException
TPixel is not a built-in pixel struct.
ArgumentOutOfRangeException
width or height is not positive.
ImageResourceLimitException
The image exceeds a limit of CustomImageDecodeContext.Configuration.
InvalidOperationException
The call that received the context has returned.