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

GifReader Class

This class enables you to read GIF images.

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

Syntax

Visual Basic
Public NotInheritable Class GifReader _
	Inherits FormatReader
C#
public sealed class GifReader : FormatReader

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 process animated GIF. For example, if you need to resize an animated GIF, you can use this code:

Visual Basic
Dim bitmap As New Aurigma.GraphicsMill.Bitmap
Dim reader As New Aurigma.GraphicsMill.Codecs.GifReader("C:\animated2.gif")
Dim writer As New Aurigma.GraphicsMill.Codecs.GifWriter("C:\animatedsmall.gif")

writer.GlobalPalette = reader.GlobalPalette
writer.BackgroundEntryIndex = reader.BackgroundEntryIndex
writer.PlaybackCount = reader.PlaybackCount
writer.SynchronizationMode = reader.SynchronizationMode

For i As Integer = 0 To reader.FrameCount - 1
    Dim frame As Aurigma.GraphicsMill.Codecs.GifFrame = reader.LoadFrame(i)

    frame.GetBitmap(bitmap)

    bitmap.Transforms.Resize(bitmap.Width \ 2, bitmap.Height \ 2, _
        Aurigma.GraphicsMill.Transforms.InterpolationMode.LowQuality)

    frame.SetBitmap(bitmap)

    frame.Top = frame.Top \ 2
    frame.Left = frame.Left \ 2

    writer.AddFrame(frame)

    frame.Dispose()
Next

writer.Dispose()
reader.Dispose()
bitmap.Dispose()
C#
Aurigma.GraphicsMill.Bitmap bitmap = new Aurigma.GraphicsMill.Bitmap();
Aurigma.GraphicsMill.Codecs.GifReader reader = 
    new Aurigma.GraphicsMill.Codecs.GifReader(@"C:\animated2.gif");
Aurigma.GraphicsMill.Codecs.GifWriter writer = 
    new Aurigma.GraphicsMill.Codecs.GifWriter(@"C:\animatedsmall.gif");

writer.GlobalPalette = reader.GlobalPalette;
writer.BackgroundEntryIndex = reader.BackgroundEntryIndex;
writer.PlaybackCount = reader.PlaybackCount;
writer.SynchronizationMode = reader.SynchronizationMode;

for (int i = 0; i < reader.FrameCount - 1; i++)
{
    Aurigma.GraphicsMill.Codecs.GifFrame frame = 
        (Aurigma.GraphicsMill.Codecs.GifFrame)(reader.LoadFrame(i));

    frame.GetBitmap(bitmap);

    bitmap.Transforms.Resize(bitmap.Width / 2, bitmap.Height / 2, 
        Aurigma.GraphicsMill.Transforms.InterpolationMode.LowQuality);

    frame.SetBitmap(bitmap);

    frame.Top = frame.Top / 2;
    frame.Left = frame.Left / 2;

    writer.AddFrame(frame);

    frame.Dispose();
}

writer.Dispose();
reader.Dispose();
bitmap.Dispose();

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





See Also

Reference