GifEncoderEncodeImageAsync Method

Encodes the specified imageData as a GIF image asynchronously, and writes it into the specified stream.

Definition

Namespace: KGySoft.Drawing.Imaging
Assembly: KGySoft.Drawing.Core (in KGySoft.Drawing.Core.dll) Version: 8.2.0
C#
public static Task EncodeImageAsync(
	IReadableBitmapData imageData,
	Stream stream,
	IQuantizer? quantizer = null,
	IDitherer? ditherer = null,
	TaskConfig? asyncConfig = null
)

Parameters

imageData  IReadableBitmapData
The image data to write. Non-indexed images will be quantized by using the specified quantizer, or, if that is not set, by the Wu quantizer or Grayscale quantizer, depending on the pixel format.
stream  Stream
The stream to save the encoded image into.
quantizer  IQuantizer  (Optional)
An optional IQuantizer instance to determine the colors of the result. If and imageData is not an indexed image or the palette contains multiple alpha entries, then the Wu or Grayscale quantizer will be used. This parameter is optional.
Default value: .
ditherer  IDitherer  (Optional)
The ditherer to be used. 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

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 the quantizing session if imageData has a non-indexed pixel format, or when quantizer is set.

  Tip

See the Remarks section of the EncodeImage method for more details.

Exceptions

ArgumentNullExceptionimageData or stream is .

See Also