SKBitmapExtensionsConvertPixelFormatAsync(SKBitmap, IQuantizer, IDitherer, SKColorType, SKAlphaType, WorkingColorSpace, TaskConfig) Method

Converts the pixel format of this bitmap asynchronously, using the specified colorType, alphaType and targetColorSpace.

Definition

Namespace: KGySoft.Drawing.SkiaSharp
Assembly: KGySoft.Drawing.SkiaSharp (in KGySoft.Drawing.SkiaSharp.dll) Version: 10.0.0-rc.1
C#
public static Task<SKBitmap?> ConvertPixelFormatAsync(
	this SKBitmap bitmap,
	IQuantizer? quantizer,
	IDitherer? ditherer = null,
	SKColorType colorType = SKColorType.Unknown,
	SKAlphaType alphaType = SKAlphaType.Unknown,
	WorkingColorSpace targetColorSpace = WorkingColorSpace.Default,
	TaskConfig? asyncConfig = null
)

Parameters

bitmap  SKBitmap
The original bitmap to convert.
quantizer  IQuantizer
An optional IQuantizer instance to determine the colors of the result. Can be to pick a quantizer automatically that matches the other parameters. If no further parameters are specified, then the original pixel format is preserved while colors are optionally quantized.
ditherer  IDitherer  (Optional)
The ditherer to be used. Might be ignored if quantizer is not specified and colorType represents a higher bits-per-pixel per color channel format. This parameter is optional.
Default value: .
colorType  SKColorType  (Optional)
Determines the ColorType property of the result SKBitmap. Can be Unknown to use the original color type of the source bitmap. This parameter is optional.
Default value: Unknown.
alphaType  SKAlphaType  (Optional)
Determines the AlphaType property of the result SKBitmap. It might be ignored if the colorType cannot have the specified alpha type. Can be Unknown to use the original alpha type of the source bitmap. This parameter is optional.
Default value: Unknown.
targetColorSpace  WorkingColorSpace  (Optional)
Determines both the ColorSpace property of the result SKBitmap, and also the working color space if quantizer is . Can be Default to preserve the original color space. This parameter is optional.
Default value: Default.
asyncConfig  TaskConfig  (Optional)
The configuration of the asynchronous operation such as parallelization, cancellation, reporting progress, etc. When Progress is set in this parameter, then this library always passes a DrawingOperation instance to the generic methods of the IAsyncProgress interface. This parameter is optional.
Default value: .

Return Value

TaskSKBitmap
A task that represents the asynchronous operation. Its result is an SKBitmap instance converted from the specified bitmap, or , if the operation was canceled and the ThrowIfCanceled property of the asyncConfig parameter was .

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type SKBitmap. When you use instance method syntax to call this method, omit the first parameter. For more information, see Extension Methods (Visual Basic) or Extension Methods (C# Programming Guide).

Remarks

This method is not a blocking call even if the MaxDegreeOfParallelism property of the asyncConfig parameter is 1.

Exceptions

ArgumentNullExceptionbitmap is .
ArgumentOutOfRangeExceptioncolorType, alphaType or targetColorSpace does not specify a defined value.

See Also