See the Remarks section for details.
Assembly: KGySoft.Drawing (in KGySoft.Drawing.dll) Version: 5.1.0
public static void SaveAsGif( this Image image, Stream stream, IQuantizer quantizer = null, IDitherer ditherer = null )
<ExtensionAttribute> Public Shared Sub SaveAsGif ( image As Image, stream As Stream, Optional quantizer As IQuantizer = Nothing, Optional ditherer As IDitherer = Nothing )
public: [ExtensionAttribute] static void SaveAsGif( Image^ image, Stream^ stream, IQuantizer^ quantizer = nullptr, IDitherer^ ditherer = nullptr )
[<ExtensionAttribute>] static member SaveAsGif : image : Image * stream : Stream * ?quantizer : IQuantizer * ?ditherer : IDitherer (* Defaults: let _quantizer = defaultArg quantizer null let _ditherer = defaultArg ditherer null *) -> unit
- Type: System.DrawingImage
The image to save. If image contains multiple images other than animated GIF frames, then only the current image will be saved.
- Type: System.IOStream
The stream to save the image into.
- quantizer (Optional)
- Type: KGySoft.Drawing.ImagingIQuantizer
If image is a non-indexed one, then specifies the quantizer to be used to determine the colors of the saved image. If , then the target colors will be optimized for the actual colors in the image. This parameter is optional.
Default value: .
- ditherer (Optional)
- Type: KGySoft.Drawing.ImagingIDitherer
If a quantization has to be performed can specifies the ditherer to be used. If , then no dithering will be performed. This parameter is optional.
Default value: .
Usage NoteIn Visual Basic and C#, you can call this method as an instance method on any object of type Image. When you use instance method syntax to call this method, omit the first parameter. For more information, see Extension Methods (Visual Basic) or Extension Methods (C# Programming Guide).
|ArgumentNullException||image or stream is .|
|InvalidOperationException||No built-in encoder was found or the saving fails in the current operating system.|
The image can only be saved if a built-in GIF encoder is available in the current operating system.
If image is an animated GIF, then the whole animation will be saved (can depend on the operating system).
The image will be saved always with a Format8bppIndexed format, though the palette can have less than 256 colors.
The GIF format supports single bit transparency only.
Images with PixelFormats other than Format8bppIndexed are converted to Format8bppIndexed before saving (including other indexed formats); otherwise, the built-in GIF encoder (at least on Windows) would save the image with a fixed palette and transparency would be lost.
|On Linux the built-in GIF encoder turns transparent palette entries opaque.|
If quantizer is and image has a non-indexed pixel format, then a quantizer is automatically selected for optimizing the palette. The auto selected quantizer is obtained by the PredefinedColorsQuantizer.Grayscale method for the Format16bppGrayScale pixel format, and by the OptimizedPaletteQuantizer.Wu method for any other pixel formats.
If ditherer is , then no ditherer will be auto-selected for the quantization.