←Select platform

AnimationBackground Property

Summary
Gets or sets the animation background color used when saving GIF files.
Syntax
C#
Objective-C
C++/CLI
Java
Python
public RasterColor AnimationBackground { get; set; } 
@property (nonatomic, copy) LTRasterColor *animationBackground; 
public RasterColor getAnimationBackground() 
public void setAnimationBackground(RasterColor color) 
public: 
property RasterColor AnimationBackground { 
   RasterColor get(); 
   void set (    RasterColor ); 
} 
AnimationBackground # get and set (CodecsGifSaveOptions) 

Property Value

The animation background color used when saving GIF files. The default value is #FF000000.

Remarks

AnimationBackground is only used when the value of UseAnimationBackground is set to true.

Example
C#
Java
using Leadtools; 
using Leadtools.Codecs; 
 
using Leadtools.ImageProcessing.Core; 
using Leadtools.Pdf; 
 
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:\LEADTOOLS23\Resources\Images"; 
} 
 
import java.io.File; 
import java.io.IOException; 
import java.net.URI; 
import java.net.URISyntaxException; 
import java.nio.file.Paths; 
 
import org.junit.*; 
import org.junit.runner.JUnitCore; 
import org.junit.runner.Result; 
import org.junit.runner.notification.Failure; 
import static org.junit.Assert.*; 
 
import leadtools.*; 
import leadtools.codecs.*; 
import leadtools.imageprocessing.core.MinMaxBitsCommand; 
 
 
public void codecsGifOptionsExample() { 
   final String LEAD_VARS_IMAGES_DIR = "C:\\LEADTOOLS23\\Resources\\Images"; 
   RasterCodecs codecs = new RasterCodecs(); 
   String srcFileName = combine(LEAD_VARS_IMAGES_DIR, "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.getGif().hasAnimationLoop()) { 
      codecs.getOptions().getGif().getLoad().setAnimationLoop(imageInfo.getGif().getAnimationLoop()); // CodecsGifOptions 
                                                                                                      // & 
                                                                                                      // CodecsGifLoadOptions 
                                                                                                      // reference 
      if (imageInfo.getGif().getAnimationLoop() > 10) 
         codecs.getOptions().getGif().getSave().setAnimationLoop(10); // CodecsGifSaveOptions reference 
   } 
 
   // if this image that you want to load uses the Animation loop then use it in 
   // the save options. 
   codecs.getOptions().getGif().getSave().setUseAnimationLoop(imageInfo.getGif().hasAnimationLoop()); 
 
   // if this image that you want to load uses the Animation Background then use it 
   // in the save options. 
   if (imageInfo.getGif().hasAnimationBackground()) { 
      codecs.getOptions().getGif().getSave().setAnimationBackground(imageInfo.getGif().getAnimationBackground()); 
      codecs.getOptions().getGif().getSave().setUseAnimationBackground(false); 
   } 
 
   // if this image that you want to load uses the Animation Palette then use it in 
   // the save options. 
   if (imageInfo.getGif().hasAnimationPalette()) 
      codecs.getOptions().getGif().getSave().setUseAnimationPalette(imageInfo.getGif().hasAnimationPalette()); 
 
   // if this image that you want to load uses the Intrlaced option, then use it 
   // otherwise don't use it. 
   codecs.getOptions().getGif().getSave().setInterlaced(imageInfo.getGif().isInterlaced()); 
 
   codecs.getOptions().getGif().getSave().setAnimationWidth(imageInfo.getGif().getAnimationWidth()); 
   codecs.getOptions().getGif().getSave().setAnimationHeight(imageInfo.getGif().getAnimationHeight()); 
 
   RasterImage srcImage = codecs.load(srcFileName); 
 
   codecs.save( 
      srcImage,  
      combine(LEAD_VARS_IMAGES_DIR, "gif1.gif"),  
      RasterImageFormat.GIF, 
      srcImage.getBitsPerPixel(),  
      1,  
      srcImage.getPageCount(),  
      1,  
      CodecsSavePageMode.OVERWRITE 
   ); 
 
   // change some save options and save the image in a new file. 
   codecs.getOptions().getGif().getSave().setUseAnimationLoop(true); 
   codecs.getOptions().getGif().getSave().setAnimationLoop(1); 
   codecs.getOptions().getGif().getSave().setAnimationWidth(imageInfo.getGif().getAnimationWidth() + 100); 
   codecs.getOptions().getGif().getSave().setAnimationHeight(imageInfo.getGif().getAnimationHeight() + 100); 
 
   // Saving the image after the Gif setting. 
   String outputFileName = combine(LEAD_VARS_IMAGES_DIR, "gif2.gif"); 
   codecs.save(srcImage, outputFileName, RasterImageFormat.GIF, srcImage.getBitsPerPixel(), 1, 
         srcImage.getPageCount(), 1, CodecsSavePageMode.OVERWRITE); 
 
   assertTrue("File unsuccessfully saved to " + outputFileName, (new File(outputFileName)).exists()); 
   System.out.printf("File successfully saved to %s%n", outputFileName); 
       
   // Clean up 
   srcImage.dispose(); 
   codecs.dispose(); 
} 
Requirements

Target Platforms

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

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