ReadableBitmapDataExtensionsToWriteableBitmapAsync(IReadableBitmapData, IQuantizer, IDitherer, TaskConfig) Method

Converts the specified source to a WriteableBitmap asynchronously, using an optionally specified quantizer and ditherer.

Definition

Namespace: KGySoft.Drawing.WinUI
Assembly: KGySoft.Drawing.WinUI (in KGySoft.Drawing.WinUI.dll) Version: 7.0.0-preview.4
C#
public static Task<WriteableBitmap?> ToWriteableBitmapAsync(
	this IReadableBitmapData source,
	IQuantizer quantizer,
	IDitherer ditherer = null,
	TaskConfig asyncConfig = null
)

Parameters

source  IReadableBitmapData
The source IReadableBitmapData instance to covert.
quantizer  IQuantizer
An IQuantizer instance to use for the conversion, or to do the conversion without reducing the colors.
ditherer  IDitherer  (Optional)
An IDitherer instance to use for the conversion or to do the conversion without dithering. This parameter is optional.
Default value: .
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

TaskWriteableBitmap
A task that represents the asynchronous operation. Its result is a WriteableBitmap instance that has the same content as the specified source, or , if the operation was canceled and the ThrowIfCanceledproperty 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 IReadableBitmapData. 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

ArgumentNullExceptionsource is .
COMExceptionCould not create the result WriteableBitmap on the current thread. Note that this method must be called on the UI thread.

See Also