ImageExtensionsBeginConvertPixelFormat(Image, PixelFormat, Color, Color, Byte, AsyncConfig) Method

Begins to convert the specified image to a Bitmap of the desired PixelFormat asynchronously.

Definition

Namespace: KGySoft.Drawing
Assembly: KGySoft.Drawing (in KGySoft.Drawing.dll) Version: 8.1.0
C#
public static IAsyncResult BeginConvertPixelFormat(
	this Image image,
	PixelFormat newPixelFormat,
	Color[]? palette,
	Color backColor = default,
	byte alphaThreshold = 128,
	AsyncConfig? asyncConfig = null
)

Parameters

image  Image
The original image to convert.
newPixelFormat  PixelFormat
The desired new pixel format.
palette  Color
The desired target palette if newPixelFormat is an indexed format. If , then the source palette is taken from the source image 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 newPixelFormat.
backColor  Color  (Optional)
If newPixelFormat does not support alpha or supports only single-bit alpha, then specifies the color of the background. Source pixels with alpha, which will be opaque in the result will be blended with this color. The Color.A property of the background color is ignored. This parameter is optional.
Default value: Empty, which has the same RGB values as Black.
alphaThreshold  Byte  (Optional)
If newPixelFormat can represent only single-bit alpha or newPixelFormat is an indexed format and the target palette contains a transparent color, then specifies a threshold value for the Color.A property, under which the color is considered transparent. If 0, then the result will not have transparent pixels. This parameter is optional.
Default value: 128.
asyncConfig  AsyncConfig  (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

IAsyncResult
An IAsyncResult that represents the asynchronous operation, which could still be pending.

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type Image. 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

In .NET Framework 4.0 and above you can use also the ConvertPixelFormatAsync(Image, PixelFormat, Color, Color, Byte, TaskConfig) method.

To get the result or the exception that occurred during the operation you have to call the EndConvertPixelFormat method.

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

See Also