GifEncoderBeginEncodeHighColorImage Method

Begins to encode the specified imageData as a multi-layered, single frame GIF image, writing it into the specified stream and 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 IAsyncResult BeginEncodeHighColorImage(
	IReadableBitmapData imageData,
	Stream stream,
	bool allowFullScan = false,
	Color32 backColor = default,
	byte alphaThreshold = 128,
	AsyncConfig? 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  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.

Remarks

In .NET Framework 4.0 and above you can use also the EncodeHighColorImageAsync method.

To finish the operation and to get the exception that occurred during the operation you have to call the EndEncodeHighColorImage method.

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