ImageExtensions.SaveAsGif Method (Image, Stream, Color[])

KGy SOFT Drawing Libraries

ImageExtensionsSaveAsGif Method (Image, Stream, Color) KGy SOFT Drawing Libraries Help
Saves the specified image as a GIF image.
See the Remarks section for the differences compared to the Image.Save(Stream,ImageFormat) method.

Namespace: KGySoft.Drawing
Assembly: KGySoft.Drawing (in KGySoft.Drawing.dll) Version: 4.6.0
Syntax

public static void SaveAsGif(
	this Image image,
	Stream stream,
	Color[] palette
)
<ExtensionAttribute>
Public Shared Sub SaveAsGif ( 
	image As Image,
	stream As Stream,
	palette As Color()
)
public:
[ExtensionAttribute]
static void SaveAsGif(
	Image^ image, 
	Stream^ stream, 
	array<Color>^ palette
)
[<ExtensionAttribute>]
static member SaveAsGif : 
        image : Image * 
        stream : Stream * 
        palette : Color[] -> unit 

Parameters

image
Type: System.DrawingImage
The image to save. If image contains multiple images or frames, then the current image will be saved. Animated GIF can be saved only if palette is .
stream
Type: System.IOStream
The stream to save the image into.
palette
Type: System.DrawingColor
The desired custom palette to use. If , and a palette cannot be taken from the source image, then a default palette will be used.

Usage Note

In 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).
Remarks

When an image is saved by the Image.Save(Stream,ImageFormat) method using the GIF image format, then the original palette of an indexed source image and transparency can be lost in many cases. Unless the source image is already a 8 bpp one, the built-in encoder will use a fixed palette and dithers the image, while transparency will be lost.

This method preserves transparency of fully transparent pixels unless palette is specified and does not contain the transparent color.

See Also

Reference