Click or drag to resize

GifDecoder Class

An ImageDecoder used to read Compuserve Graphics Interchange (GIF) images from a Stream.

Inheritance Hierarchy
System.Object
  Atalasoft.Imaging.Codec.ImageDecoder
    Atalasoft.Imaging.Codec.MultiFramedImageDecoder
      Atalasoft.Imaging.Codec.GifDecoder

Namespace:  Atalasoft.Imaging.Codec
Assembly:  Atalasoft.dotImage (in Atalasoft.dotImage.dll) Version: 11.4.0.9.0.377 (.NET 4.5.2, x86)
Syntax
public class GifDecoder : MultiFramedImageDecoder, IDisposable

The GifDecoder type exposes the following members.

Constructors
  NameDescription
Public methodGifDecoder
Initializes a new instance of a %GifDecoder%.
Top
Properties
  NameDescription
Public propertyFrames
Gets a GifFrameCollection from an animated GIF.
Public propertySupportedImageType Obsolete.
Returns a Gif ImageType enumeration value.
(Overrides ImageDecoder.SupportedImageType.)
Top
Methods
  NameDescription
Public methodDispose()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
Protected methodDispose(Boolean)
Releases unmanaged and - optionally - managed resources.
Public methodEquals
Determines whether the specified object is equal to the current object.
(Inherited from Object.)
Protected methodFinalize
Finalizes an instance of the GifDecoder class.
(Overrides Object.Finalize().)
Public methodGetFrameCount

Gets the number of frames in a GIF.

(Overrides MultiFramedImageDecoder.GetFrameCount(Stream).)
Public methodGetHashCode
Serves as the default hash function.
(Inherited from Object.)
Public methodGetImageInfo(Stream)
Retreive information from a Gif image stored in a Stream without decoding the image data.
(Overrides ImageDecoder.GetImageInfo(Stream).)
Public methodGetImageInfo(Stream, Int32)
Retreive information from a specified frame in a Gif image stored in a Stream without decoding the image data.
(Overrides MultiFramedImageDecoder.GetImageInfo(Stream, Int32).)
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Public methodIsValidFormat

Returns true if the specified Stream contains a Gif image.

(Overrides ImageDecoder.IsValidFormat(Stream).)
Protected methodMemberwiseClone
Creates a shallow copy of the current Object.
(Inherited from Object.)
Public methodRead(Stream, ProgressEventHandler)
Returns an %AtalaImage% from a Stream containing a Gif encoded image.
(Overrides ImageDecoder.Read(Stream, ProgressEventHandler).)
Public methodRead(Stream, Int32, ProgressEventHandler)
Returns a specified frame to an %AtalaImage% from a Stream containing an animated Gif encoded image.
(Overrides MultiFramedImageDecoder.Read(Stream, Int32, ProgressEventHandler).)
Public methodToString
Returns a string that represents the current object.
(Inherited from Object.)
Top
Remarks

By default, when opening a Gif image using the AtalaImage or Workspace objects, this decoder will automatically be selected from the RegisteredDecoders and does not have to be explicitly set.

Examples
Animated (C#)
// Open the file for reading.
FileStream fs = new FileStream(this.fileName, FileMode.Open, FileAccess.Read);

// Make sure it's a valid GIF.
GifDecoder gif = new GifDecoder();
if (gif.IsValidFormat(fs) == false)
{
    fs.Close();
    return;
}

// Seek back to the beginning of the file.
fs.Seek(0, SeekOrigin.Begin);

// The first time you access the GetFrameCount property,
// all of the frames are read into memory and are waiting
// for you to access them.
int count = gif.GetFrameCount(fs);

// Use the GifFrame properties to reconstruct the animation.
GifFrameCollection col = gif.Frames;

// Close the file.
fs.Close();
AnimatedVB (Visual Basic)
' Open the file for reading.
Dim fs As FileStream =  New FileStream(Me.fileName,FileMode.Open,FileAccess.Read) 

' Make sure it's a valid GIF.
Dim gif As GifDecoder =  New GifDecoder() 
If gif.IsValidFormat(fs) = False Then
    fs.Close()
    Return
End If

' Seek back to the beginning of the file.
fs.Seek(0, SeekOrigin.Begin)

' The first time you access the GetFrameCount property,
' all of the frames are read into memory and are waiting
' for you to access them.
Dim count As Integer =  gif.GetFrameCount(fs) 

' Use the GifFrame properties to reconstruct the animation.
Dim col As GifFrameCollection =  gif.Frames 

' Close the file.
fs.Close()
See Also