GifEncoderEncodeImage Method

Encodes the specified imageData as a GIF image 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 void EncodeImage(
	IReadableBitmapData imageData,
	Stream stream,
	IQuantizer? quantizer = null,
	IDitherer? ditherer = 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: .

Remarks

  Note

This method adjusts the degree of parallelization automatically, blocks the caller, and does not support cancellation or reporting progress. Use the BeginEncodeImage or EncodeImageAsync (in .NET Framework 4.0 and above) methods for asynchronous call and to set up cancellation or for reporting progress.

To encode an Image you can use also the ImageExtensions.SaveAsGif methods that provide a higher level access.

To create a GIF completely manually you can create a GifEncoder instance that provides a lower level access.

If quantizer is specified, then it will be used even for already indexed images.

If quantizer is an OptimizedPaletteQuantizer, then the palette of the result image will be adjusted for the actual image content.

Exceptions

ArgumentNullExceptionimageData or stream is .

See Also