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 CustomImageDecodeContextRemarks
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
| Name | Description |
|---|---|
| CancellationToken | Gets the token of the operation. Check it between rows or frames of a long decode. |
| Configuration | Gets the configuration of the operation: its resource limits and its parallelism. |
| FrameLimit | 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. |
| IdentifyMode | Gets the mode of an identification, or null when the call decodes the image. |
| RequestedPixelFormat | 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. |
CancellationToken
CustomImageDecodeContext.csGets the token of the operation. Check it between rows or frames of a long decode.
public CancellationToken CancellationToken { get; }Property value
Configuration
CustomImageDecodeContext.csGets the configuration of the operation: its resource limits and its parallelism.
public ImageConfiguration Configuration { get; }Property value
FrameLimit
CustomImageDecodeContext.csGets 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
IdentifyMode
CustomImageDecodeContext.csGets the mode of an identification, or null when the call decodes the image.
public ImageIdentifyMode? IdentifyMode { get; }Property value
RequestedPixelFormat
CustomImageDecodeContext.csGets 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
Methods
| Name | Description |
|---|---|
| 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.csCreates 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
pixelFormatPixelFormat- The pixel format.
widthint- The width. Must be positive.
heightint- The height. Must be positive.
Returns
Image The image, an Image<TPixel> of the pixel type of pixelFormat.
Exceptions
ArgumentOutOfRangeExceptionpixelFormatis not defined, orwidthorheightis 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.csCreates a single-frame still image whose pixels are all zero, charged to the operation.
Type parameters
TPixel- The pixel type.
Parameters
Returns
Image<TPixel> The image. Add frames with Image<TPixel>.AppendFrame.
Exceptions
NotSupportedExceptionTPixelis not a built-in pixel struct.ArgumentOutOfRangeExceptionwidthorheightis not positive.ImageResourceLimitException- The image exceeds a limit of
CustomImageDecodeContext.Configuration. InvalidOperationException- The call that received the context has returned.