BitmapDataExtensionsCloneAsync(IReadableBitmapData, KnownPixelFormat, Palette, NullableRectangle, TaskConfig) Method

Gets the clone of the specified portion of source with the specified pixelFormat and palette asynchronously.

Definition

Namespace: KGySoft.Drawing.Imaging
Assembly: KGySoft.Drawing.Core (in KGySoft.Drawing.Core.dll) Version: 8.1.0
C#
public static Task<IReadWriteBitmapData?> CloneAsync(
	this IReadableBitmapData source,
	KnownPixelFormat pixelFormat,
	Palette? palette,
	Rectangle? sourceRectangle = null,
	TaskConfig? asyncConfig = null
)

Parameters

source  IReadableBitmapData
An IReadableBitmapData instance to be cloned.
pixelFormat  KnownPixelFormat
The desired pixel format of the result.
palette  Palette
If pixelFormat is an indexed format, then specifies the desired Palette of the returned IReadWriteBitmapData instance. It determines also the BackColor and AlphaThreshold properties of the result. If , then the target palette is taken from source if it also has a palette of no more entries than the target indexed format can have; otherwise, a default palette will be used based on pixelFormat.
sourceRectangle  NullableRectangle  (Optional)
A Rectangle that specifies the portion of the source to be cloned, or to clone the entire source. 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

TaskIReadWriteBitmapData
A task that represents the asynchronous operation. Its result is the new IReadWriteBitmapData instance that represents the clone of the specified source, 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 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 .
ArgumentOutOfRangeExceptionpixelFormat does not specify a valid format.
-or-
sourceRectangle has no overlapping region with source bounds.
ArgumentExceptionpalette contains too many colors for the specified pixelFormat.

See Also