Leadtools.Codecs Send comments on this topic. | Back to Introduction - All Topics | Help Version 15.12.17
CodecsGifOptions Class
See Also  Members   Example 
Leadtools.Codecs Namespace : CodecsGifOptions Class




Provides extra options for loading and saving GIF images.

Object Model



Syntax

Visual Basic (Declaration) 
Public Class CodecsGifOptions 
Visual Basic (Usage)Copy Code
Dim instance As CodecsGifOptions
C# 
public class CodecsGifOptions 
Managed Extensions for C++ 
public __gc class CodecsGifOptions 
C++/CLI 
public ref class CodecsGifOptions 

Example

Visual BasicCopy Code
CodecsGifOptions
      Public Sub CodecsGifOptionsExample()
         RasterCodecs.Startup()
         Dim codecs As RasterCodecs = New RasterCodecs()
         Dim srcFileName As String = "C:\Program Files\LEAD Technologies\LEADTOOLS 15\Images\eye.gif"

         ' Get all Information about the Gif file that you want to load.
         Dim imageInfo As CodecsImageInfo = codecs.GetInformation(srcFileName, True)

         ' set the animation loop value.
         If imageInfo.Gif.HasAnimationLoop Then
            codecs.Options.Gif.Load.AnimationLoop = imageInfo.Gif.AnimationLoop
            If imageInfo.Gif.AnimationLoop > 10 Then
               codecs.Options.Gif.Save.AnimationLoop = 10
            End If
         End If

         ' if this image that you want to load uses the Animation loop then use it in the save options.
         codecs.Options.Gif.Save.UseAnimationLoop = imageInfo.Gif.HasAnimationLoop

         ' if this image that you want to load uses the Animation Background then use it in the save options.
         If imageInfo.Gif.HasAnimationBackground Then
            codecs.Options.Gif.Save.AnimationBackground = imageInfo.Gif.AnimationBackground
         End If

         ' if this image that you want to load uses the Animation Palette then use it in the save options.
         If imageInfo.Gif.HasAnimationPalette Then
            codecs.Options.Gif.Save.SetAnimationPalette(imageInfo.Gif.GetAnimationPalette())
         End If

         codecs.Options.Gif.Save.UseAnimationPalette = imageInfo.Gif.HasAnimationPalette

         ' if this image that you want to load uses the Intrlaced option, then use it otherwise don't use it.
         codecs.Options.Gif.Save.Interlaced = imageInfo.Gif.IsInterlaced

         codecs.Options.Gif.Save.AnimationWidth = imageInfo.Gif.AnimationWidth
         codecs.Options.Gif.Save.AnimationHeight = imageInfo.Gif.AnimationHeight

         Dim srcImage As RasterImage = codecs.Load(srcFileName)

         codecs.Save(srcImage, "C:\Program Files\LEAD Technologies\LEADTOOLS 15\Images\gif1.gif", RasterImageFormat.Gif, srcImage.BitsPerPixel, 1, srcImage.PageCount, 1, CodecsSavePageMode.Overwrite)

         'change some save options and save the image in a new file.
         codecs.Options.Gif.Save.UseAnimationLoop = True
         codecs.Options.Gif.Save.AnimationLoop = 1
         codecs.Options.Gif.Save.AnimationWidth = imageInfo.Gif.AnimationWidth + 100
         codecs.Options.Gif.Save.AnimationHeight = imageInfo.Gif.AnimationHeight + 100

         'Saving the image after the Gif setting.
         codecs.Save(srcImage, "C:\Program Files\LEAD Technologies\LEADTOOLS 15\Images\gif2.gif", RasterImageFormat.Gif, srcImage.BitsPerPixel, 1, srcImage.PageCount, 1, CodecsSavePageMode.Overwrite)

         ' Clean up
         srcImage.Dispose()
         codecs.Dispose()
         RasterCodecs.Shutdown()
      End Sub
C#Copy Code
CodecsGifOptions 
      public void CodecsGifOptionsExample() 
      { 
         RasterCodecs.Startup(); 
         RasterCodecs codecs = new RasterCodecs(); 
         string srcFileName = @"C:\Program Files\LEAD Technologies\LEADTOOLS 15\Images\eye.gif"; 
 
         // Get all Information about the Gif file that you want to load. 
         CodecsImageInfo imageInfo = codecs.GetInformation(srcFileName, true); 
 
         // set the animation loop value.  
         if (imageInfo.Gif.HasAnimationLoop) 
         { 
            codecs.Options.Gif.Load.AnimationLoop = imageInfo.Gif.AnimationLoop; 
            if (imageInfo.Gif.AnimationLoop > 10) 
               codecs.Options.Gif.Save.AnimationLoop = 10; 
         } 
 
         // if this image that you want to load uses the Animation loop then use it in the save options. 
         codecs.Options.Gif.Save.UseAnimationLoop = imageInfo.Gif.HasAnimationLoop; 
 
         // if this image that you want to load uses the Animation Background then use it in the save options. 
         if (imageInfo.Gif.HasAnimationBackground) 
            codecs.Options.Gif.Save.AnimationBackground = imageInfo.Gif.AnimationBackground; 
 
         // if this image that you want to load uses the Animation Palette then use it in the save options. 
         if (imageInfo.Gif.HasAnimationPalette) 
            codecs.Options.Gif.Save.SetAnimationPalette(imageInfo.Gif.GetAnimationPalette()); 
 
         codecs.Options.Gif.Save.UseAnimationPalette = imageInfo.Gif.HasAnimationPalette; 
 
         // if this image that you want to load uses the Intrlaced option, then use it otherwise don't use it. 
         codecs.Options.Gif.Save.Interlaced = imageInfo.Gif.IsInterlaced; 
 
         codecs.Options.Gif.Save.AnimationWidth = imageInfo.Gif.AnimationWidth; 
         codecs.Options.Gif.Save.AnimationHeight = imageInfo.Gif.AnimationHeight; 
 
         RasterImage srcImage = codecs.Load(srcFileName); 
 
         codecs.Save(srcImage, @"C:\Program Files\LEAD Technologies\LEADTOOLS 15\Images\gif1.gif", RasterImageFormat.Gif, srcImage.BitsPerPixel, 1, srcImage.PageCount, 1, CodecsSavePageMode.Overwrite); 
 
         //change some save options and save the image in a new file. 
         codecs.Options.Gif.Save.UseAnimationLoop = true; 
         codecs.Options.Gif.Save.AnimationLoop = 1; 
         codecs.Options.Gif.Save.AnimationWidth = imageInfo.Gif.AnimationWidth + 100; 
         codecs.Options.Gif.Save.AnimationHeight = imageInfo.Gif.AnimationHeight + 100; 
 
         //Saving the image after the Gif setting. 
         codecs.Save(srcImage, @"C:\Program Files\LEAD Technologies\LEADTOOLS 15\Images\gif2.gif", RasterImageFormat.Gif, srcImage.BitsPerPixel, 1, srcImage.PageCount, 1, CodecsSavePageMode.Overwrite); 
 
         // Clean up 
         srcImage.Dispose(); 
         codecs.Dispose(); 
         RasterCodecs.Shutdown(); 
      }

Inheritance Hierarchy

System.Object
   Leadtools.Codecs.CodecsGifOptions

Requirements

Target Platforms: Microsoft .NET Framework 2.0, Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family

See Also