This documentation is for the old version. Go to the latest Graphics Mill docs

GifWriter Class

This class enables you to write GIF images (both static and animated).

Namespace: Aurigma.GraphicsMill.Codecs
Assembly: Aurigma.GraphicsMill (in Aurigma.GraphicsMill.dll)

Syntax

Visual Basic
Public NotInheritable Class GifWriter _
	Inherits FormatWriter
C#
public sealed class GifWriter : FormatWriter

Remarks

The GIF format was designed by Compuserve in 1987. Since then it has become very popular for general image exchange. There are two types of GIF files; GIF87a, the original standard of 1987 and GIF89a, the revised standard of 1989. All of these formats are available for reading in Graphics Mill for .NET and GIF89a format is available for saving. Main advantage of GIF89a against GIF87a is animation and transparency support.

The GIF format is a lossless format and is good for saving any type of image that has 256 colors (or shades of gray), or fewer. This format is suitable as a generalized format for image exchange, however the color information limit in the format may require you to choose PNG, TIFF or JPEG instead of it. In general this is the best format for images with a limited number of colors, since the compression ratio is good (it is difficult to obtain better compression and stay lossless) and GIF files can be decompressed very quickly. GIF image format supports one-dimensional interlacing (a method of progressive display), this makes this format convenient for transmission images across slow communication links. That is why this format is very popular for Web graphics.

GIF format can store only indexed images. As soon as it supports animation, it can contain multiple frames. Frame can have its own position, and a number of other paramaters, as delay time, disposal method, etc.

Examples

This code sample demonstrates how to create an animated GIF file from several JPEG files. Draw attention, you can use this code to save simple GIF files too (by passing the single frame into it).

Visual Basic
Dim dir As String = "C:\Documents and Settings\All Users\Documents\My Pictures\Sample Pictures\"
Dim images As String() = {"Blue hills.jpg", "Sunset.jpg", "Water lilies.jpg", "Winter.jpg"}
Dim image As String

Dim bitmap As New Aurigma.GraphicsMill.Bitmap

Dim writer As New Aurigma.GraphicsMill.Codecs.GifWriter("C:\Slideshow.gif")

For Each image In images
    bitmap.Load(dir & image)

    bitmap.ColorManagement.PaletteEntryCount = 32
    bitmap.ColorManagement.ConvertToIndexed(8, Aurigma.GraphicsMill.ColorPaletteType.Adaptive, _
        Nothing)

    Dim frame As New Aurigma.GraphicsMill.Codecs.GifFrame
    frame.Delay = 100
    frame.SetBitmap(bitmap)

    writer.AddFrame(frame)

    frame.Dispose()
Next

bitmap.Dispose()

writer.Dispose()
C#
string dir = @"C:\Documents and Settings\All Users\Documents\My Pictures\Sample Pictures";
string[] images = {"Blue hills.jpg", "Sunset.jpg", "Water lilies.jpg", "Winter.jpg"};

using (Aurigma.GraphicsMill.Bitmap bitmap = 
           new Aurigma.GraphicsMill.Bitmap())
{
    using (Aurigma.GraphicsMill.Codecs.GifWriter writer = 
               new Aurigma.GraphicsMill.Codecs.GifWriter(@"C:\Slideshow.gif"))
    {
        foreach (string image in images)
        {
            bitmap.Load(dir + image);

            bitmap.ColorManagement.PaletteEntryCount = 32;
            bitmap.ColorManagement.ConvertToIndexed(8, 
                Aurigma.GraphicsMill.ColorPaletteType.Adaptive, null);
            
            using(Aurigma.GraphicsMill.Codecs.GifFrame frame = 
                      new Aurigma.GraphicsMill.Codecs.GifFrame())
            {
                frame.Delay = 100;
                frame.SetBitmap(bitmap);            
                writer.AddFrame(frame);
            }
        }
    }
}

Inheritance Hierarchy

Thread Safety

Static members of this type are safe for multi-threaded operations. Instance members of this type are safe for multi-threaded operations.

Object Model






Supported Pixel Formats

Member NameDescription
Format1bppIndexed1 bit per pixel. Indexed.
Format4bppIndexed4 bits per pixel. Indexed.
Format8bppIndexed8 bits per pixel. Indexed.
Format8bppGrayScale8 bits per pixel. Grayscale. 8 bits are used for luminosity level.

See Also

Reference