GifEncoderEncodeImage Method
Encodes the specified imageData as a GIF image and writes it into the specified stream.
Namespace: KGySoft.Drawing.ImagingAssembly: KGySoft.Drawing.Core (in KGySoft.Drawing.Core.dll) Version: 8.2.0
public static void EncodeImage(
IReadableBitmapData imageData,
Stream stream,
IQuantizer? quantizer = null,
IDitherer? ditherer = null
)
Public Shared Sub EncodeImage (
imageData As IReadableBitmapData,
stream As Stream,
Optional quantizer As IQuantizer = Nothing,
Optional ditherer As IDitherer = Nothing
)
public:
static void EncodeImage(
IReadableBitmapData^ imageData,
Stream^ stream,
IQuantizer^ quantizer = nullptr,
IDitherer^ ditherer = nullptr
)
static member EncodeImage :
imageData : IReadableBitmapData *
stream : Stream *
?quantizer : IQuantizer *
?ditherer : IDitherer
(* Defaults:
let _quantizer = defaultArg quantizer null
let _ditherer = defaultArg ditherer null
*)
-> unit
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: .
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.