GifEncoderBeginEncodeImage Method

Begins to encode the specified imageData as a GIF image and to write 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 IAsyncResult BeginEncodeImage(
	IReadableBitmapData imageData,
	Stream stream,
	IQuantizer? quantizer = null,
	IDitherer? ditherer = null,
	AsyncConfig? 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  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 EncodeImageAsync method.

To finish the operation and to get the exception that occurred during the operation you have to call the EndEncodeImage 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 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