←Select platform

UseAnimationLoop Property

Summary
Gets or sets a value indicating whether to use the animation loop when saving GIF files.
Syntax
C#
Objective-C
C++/CLI
Java
Python
public bool UseAnimationLoop { get; set; } 
@property (nonatomic, assign, getter=usesAnimationLoop) BOOL useAnimationLoop; 
public boolean isUseAnimationLoop() 
public void setUseAnimationLoop(boolean useAnimationLoop) 
public: 
property bool UseAnimationLoop { 
   bool get(); 
   void set (    bool ); 
} 
UseAnimationLoop # get and set (CodecsGifSaveOptions) 

Property Value

Value Description
true To use AnimationLoop when saving GIF files.
false To not use AnimationLoop when saving GIF files. The default value is false.
Example
C#
using Leadtools; 
using Leadtools.Codecs; 
 
using Leadtools.ImageProcessing.Core; 
 
public void CodecsGifOptionsExample() 
{ 
   RasterCodecs codecs = new RasterCodecs(); 
   string srcFileName = Path.Combine(LEAD_VARS.ImagesDir, "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; // CodecsGifOptions & CodecsGifLoadOptions reference 
      if (imageInfo.Gif.AnimationLoop > 10) 
         codecs.Options.Gif.Save.AnimationLoop = 10; // CodecsGifSaveOptions reference 
   } 
 
   // 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; 
      codecs.Options.Gif.Save.UseAnimationBackground = false; 
   } 
 
   // 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, Path.Combine(LEAD_VARS.ImagesDir, "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, Path.Combine(LEAD_VARS.ImagesDir, "gif2.gif"), RasterImageFormat.Gif, srcImage.BitsPerPixel, 1, srcImage.PageCount, 1, CodecsSavePageMode.Overwrite); 
 
   // Clean up 
   srcImage.Dispose(); 
   codecs.Dispose(); 
} 
 
static class LEAD_VARS 
{ 
   public const string ImagesDir = @"C:\LEADTOOLS22\Resources\Images"; 
} 
Requirements

Target Platforms

Help Version 22.0.2023.5.5
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.

Leadtools.Codecs Assembly

Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.