GifEncoderEncodeHighColorImageAsync Method

Encodes the specified imageData as a multi-layered, single frame GIF image asynchronously, ans writes it into the specified stream, preserving its original color depth.

Definition

Namespace: KGySoft.Drawing.Imaging
Assembly: KGySoft.Drawing.Core (in KGySoft.Drawing.Core.dll) Version: 8.2.0
C#
public static Task EncodeHighColorImageAsync(
	IReadableBitmapData imageData,
	Stream stream,
	bool allowFullScan = false,
	Color32 backColor = default,
	byte alphaThreshold = 128,
	TaskConfig? asyncConfig = null
)

Parameters

imageData  IReadableBitmapData
The image data to write. Possible alpha pixels might be blended with backColor but otherwise the color depth will be preserved.
stream  Stream
The stream to save the encoded animation into.
allowFullScan  Boolean  (Optional)
to allow scanning the whole image for each layers to be able to re-use the local palette of the current layer.
to expand the initial layer area to the local pixels only. This parameter is optional.
Default value: .
backColor  Color32  (Optional)
Colors with alpha (transparency), whose Color32.A field is equal to or greater than alphaThreshold will be blended with this color during the encoding. The alpha value (Color32.A field) of the specified background color is ignored. This parameter is optional.
Default value: The default value of the Color32 type, which has the same RGB values as Black.
alphaThreshold  Byte  (Optional)
Specifies a threshold value for the Color32.A field, under which a pixel is considered transparent. If 0, then the final composite image will not have transparent pixels. This parameter is optional.
Default value: 128.
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

Task
A task that represents the asynchronous operation.

Remarks

This method is not a blocking call even if the MaxDegreeOfParallelism property of the asyncConfig parameter is 1. The encoding itself cannot be parallelized. The MaxDegreeOfParallelism setting affects only some processing steps if the size of a layer exceeds a threshold.

Exceptions

ArgumentNullExceptionimageData or stream is .

See Also