Class GifImage
Namespace: Aspose.Imaging.FileFormats.Gif
Assembly: Aspose.Imaging.dll (25.7.0)
The API for Graphical Interchange Format (GIF) image file providesdevelopers with versatile tools for processing compressed raster images andanimated GIFs. Offering features like XMP metadata handling, color palettesettings, background and transparent color control, opacity settings, resize,crop, filter application, gamma corrections, contrast adjustment, grayscaletransformation, and conversion to other formats. This API empowers seamlessmanipulation and enhancement of GIF images for a wide range of applications.
[JsonObject(MemberSerialization.OptIn)]
public sealed class GifImage : RasterCachedMultipageImage, IDisposable, IObjectWithBounds, IRasterImageArgb32PixelLoader, IRasterImageRawDataLoader, IHasXmpData, IHasMetadata, IMultipageImageExt, IMultipageImage
{
}
Inheritance
object ← DisposableObject ← DataStreamSupporter ← Image ← RasterImage ← RasterCachedImage ← RasterCachedMultipageImage ← GifImage
Implements
IDisposable , IObjectWithBounds , IRasterImageArgb32PixelLoader , IRasterImageRawDataLoader , IHasXmpData , IHasMetadata , IMultipageImageExt , IMultipageImage
Inherited Members
RasterCachedMultipageImage.AdjustBrightness(int) , RasterCachedMultipageImage.AdjustContrast(float) , RasterCachedMultipageImage.AdjustGamma(float, float, float) , RasterCachedMultipageImage.AdjustGamma(float) , RasterCachedMultipageImage.Blend(Point, RasterImage, Rectangle, byte) , RasterCachedMultipageImage.BinarizeFixed(byte) , RasterCachedMultipageImage.BinarizeBradley(double, int) , RasterCachedMultipageImage.BinarizeBradley(double) , RasterCachedMultipageImage.BinarizeOtsu() , RasterCachedMultipageImage.Crop(Rectangle) , RasterCachedMultipageImage.Crop(int, int, int, int) , RasterCachedMultipageImage.Dither(DitheringMethod, int, IColorPalette) , RasterCachedMultipageImage.Grayscale() , RasterCachedMultipageImage.NormalizeHistogram() , RasterCachedMultipageImage.Rotate(float, bool, Color) , RasterCachedMultipageImage.RotateFlip(RotateFlipType) , RasterCachedMultipageImage.RotateFlipAll(RotateFlipType) , RasterCachedMultipageImage.Resize(int, int, ResizeType) , RasterCachedMultipageImage.Resize(int, int, ImageResizeSettings) , RasterCachedMultipageImage.ResizeWidthProportionally(int, ResizeType) , RasterCachedMultipageImage.ResizeHeightProportionally(int, ResizeType) , RasterCachedMultipageImage.ReplaceColor(int, byte, int) , RasterCachedMultipageImage.ReplaceNonTransparentColors(int) , RasterCachedMultipageImage.Filter(Rectangle, FilterOptionsBase) , RasterCachedMultipageImage.NormalizeAngle(bool, Color) , RasterCachedMultipageImage.CacheData() , RasterCachedMultipageImage.GetSerializedStream(ImageOptionsBase, Rectangle, out int) , RasterCachedMultipageImage.Height , RasterCachedMultipageImage.Width , RasterCachedMultipageImage.BitsPerPixel , RasterCachedMultipageImage.IsCached , RasterCachedMultipageImage.PageCount , RasterCachedMultipageImage.Pages , RasterCachedMultipageImage.HasAlpha , RasterCachedMultipageImage.HasTransparentColor , RasterCachedMultipageImage.ImageOpacity , RasterCachedMultipageImage.BackgroundColor , RasterCachedMultipageImage.XmpData , RasterCachedMultipageImage.PageExportingAction , RasterCachedImage.CacheData() , RasterCachedImage.Blend(Point, RasterImage, Rectangle, byte) , RasterCachedImage.Resize(int, int, ResizeType) , RasterCachedImage.Resize(int, int, ImageResizeSettings) , RasterCachedImage.RotateFlip(RotateFlipType) , RasterCachedImage.Rotate(float, bool, Color) , RasterCachedImage.Crop(Rectangle) , RasterCachedImage.Dither(DitheringMethod, int, IColorPalette) , RasterCachedImage.Grayscale() , RasterCachedImage.NormalizeHistogram() , RasterCachedImage.BinarizeFixed(byte) , RasterCachedImage.BinarizeOtsu() , RasterCachedImage.BinarizeBradley(double, int) , RasterCachedImage.BinarizeBradley(double) , RasterCachedImage.AdjustBrightness(int) , RasterCachedImage.AdjustContrast(float) , RasterCachedImage.AdjustGamma(float, float, float) , RasterCachedImage.AdjustGamma(float) , RasterCachedImage.IsCached , RasterImage.RemoveMetadata() , RasterImage.Save(Stream, ImageOptionsBase, Rectangle) , RasterImage.GetModifyDate(bool) , RasterImage.Dither(DitheringMethod, int) , RasterImage.Dither(DitheringMethod, int, IColorPalette) , RasterImage.GetDefaultPixels(Rectangle, IPartialArgb32PixelLoader) , RasterImage.GetDefaultRawData(Rectangle, IPartialRawDataLoader, RawDataSettings) , RasterImage.GetDefaultArgb32Pixels(Rectangle) , RasterImage.GetDefaultRawData(Rectangle, RawDataSettings) , RasterImage.GetArgb32Pixel(int, int) , RasterImage.GetPixel(int, int) , RasterImage.SetArgb32Pixel(int, int, int) , RasterImage.SetPixel(int, int, Color) , RasterImage.ReadScanLine(int) , RasterImage.ReadArgb32ScanLine(int) , RasterImage.WriteScanLine(int, Color[]) , RasterImage.WriteArgb32ScanLine(int, int[]) , RasterImage.LoadPartialArgb32Pixels(Rectangle, IPartialArgb32PixelLoader) , RasterImage.LoadPartialPixels(Rectangle, IPartialPixelLoader) , RasterImage.LoadArgb32Pixels(Rectangle) , RasterImage.LoadArgb64Pixels(Rectangle) , RasterImage.LoadPartialArgb64Pixels(Rectangle, IPartialArgb64PixelLoader) , RasterImage.LoadPixels(Rectangle) , RasterImage.LoadCmykPixels(Rectangle) , RasterImage.LoadCmyk32Pixels(Rectangle) , RasterImage.LoadRawData(Rectangle, RawDataSettings, IPartialRawDataLoader) , RasterImage.LoadRawData(Rectangle, Rectangle, RawDataSettings, IPartialRawDataLoader) , RasterImage.SaveRawData(byte[], int, Rectangle, RawDataSettings) , RasterImage.SaveArgb32Pixels(Rectangle, int[]) , RasterImage.SavePixels(Rectangle, Color[]) , RasterImage.SaveCmykPixels(Rectangle, CmykColor[]) , RasterImage.SaveCmyk32Pixels(Rectangle, int[]) , RasterImage.SetResolution(double, double) , RasterImage.SetPalette(IColorPalette, bool) , RasterImage.Resize(int, int, ImageResizeSettings) , RasterImage.Rotate(float, bool, Color) , RasterImage.Rotate(float) , RasterImage.BinarizeFixed(byte) , RasterImage.BinarizeOtsu() , RasterImage.BinarizeBradley(double) , RasterImage.BinarizeBradley(double, int) , RasterImage.Blend(Point, RasterImage, Rectangle, byte) , RasterImage.Blend(Point, RasterImage, byte) , RasterImage.Grayscale() , RasterImage.NormalizeHistogram() , RasterImage.AdjustBrightness(int) , RasterImage.AdjustContrast(float) , RasterImage.AdjustGamma(float, float, float) , RasterImage.AdjustGamma(float) , RasterImage.GetSkewAngle() , RasterImage.NormalizeAngle() , RasterImage.NormalizeAngle(bool, Color) , RasterImage.Filter(Rectangle, FilterOptionsBase) , RasterImage.ReplaceColor(Color, byte, Color) , RasterImage.ReplaceColor(int, byte, int) , RasterImage.ReplaceNonTransparentColors(Color) , RasterImage.ReplaceNonTransparentColors(int) , RasterImage.ToBitmap() , RasterImage.PremultiplyComponents , RasterImage.UseRawData , RasterImage.UpdateXmpData , RasterImage.XmpData , RasterImage.RawIndexedColorConverter , RasterImage.RawCustomColorConverter , RasterImage.RawFallbackIndex , RasterImage.RawDataSettings , RasterImage.UsePalette , RasterImage.RawDataFormat , RasterImage.RawLineSize , RasterImage.IsRawDataAvailable , RasterImage.HorizontalResolution , RasterImage.VerticalResolution , RasterImage.HasTransparentColor , RasterImage.HasAlpha , RasterImage.TransparentColor , RasterImage.ImageOpacity , Image.CanLoad(string) , Image.CanLoad(string, LoadOptions) , Image.CanLoad(Stream) , Image.CanLoad(Stream, LoadOptions) , Image.Create(ImageOptionsBase, int, int) , Image.Create(Image[]) , Image.Create(MultipageCreateOptions) , Image.Create(string[], bool) , Image.Create(string[]) , Image.Create(Image[], bool) , Image.GetFileFormat(string) , Image.GetFileFormat(Stream) , Image.GetFittingRectangle(Rectangle, int, int) , Image.GetFittingRectangle(Rectangle, int[], int, int) , Image.Load(string, LoadOptions) , Image.Load(string) , Image.Load(Stream, LoadOptions) , Image.Load(Stream) , Image.GetProportionalWidth(int, int, int) , Image.GetProportionalHeight(int, int, int) , Image.RemoveMetadata() , Image.CanSave(ImageOptionsBase) , Image.Resize(int, int) , Image.Resize(int, int, ResizeType) , Image.Resize(int, int, ImageResizeSettings) , Image.GetDefaultOptions(object[]) , Image.GetOriginalOptions() , Image.ResizeWidthProportionally(int) , Image.ResizeHeightProportionally(int) , Image.ResizeWidthProportionally(int, ResizeType) , Image.ResizeHeightProportionally(int, ResizeType) , Image.ResizeWidthProportionally(int, ImageResizeSettings) , Image.ResizeHeightProportionally(int, ImageResizeSettings) , Image.RotateFlip(RotateFlipType) , Image.Rotate(float) , Image.Crop(Rectangle) , Image.Crop(int, int, int, int) , Image.Save() , Image.Save(string) , Image.Save(string, ImageOptionsBase) , Image.Save(string, ImageOptionsBase, Rectangle) , Image.Save(Stream, ImageOptionsBase) , Image.Save(Stream, ImageOptionsBase, Rectangle) , Image.GetSerializedStream(ImageOptionsBase, Rectangle, out int) , Image.SetPalette(IColorPalette, bool) , Image.BitsPerPixel , Image.Bounds , Image.Container , Image.Height , Image.Palette , Image.UsePalette , Image.Size , Image.Width , Image.InterruptMonitor , Image.BufferSizeHint , Image.AutoAdjustPalette , Image.HasBackgroundColor , Image.FileFormat , Image.BackgroundColor , DataStreamSupporter.CacheData() , DataStreamSupporter.Save() , DataStreamSupporter.Save(Stream) , DataStreamSupporter.Save(string) , DataStreamSupporter.Save(string, bool) , DataStreamSupporter.DataStreamContainer , DataStreamSupporter.IsCached , DisposableObject.Dispose() , DisposableObject.Disposed , object.GetType() , object.ToString() , object.Equals(object?) , object.Equals(object?, object?) , object.ReferenceEquals(object?, object?) , object.GetHashCode()
Examples
Export of part of animation from GIF image based on time interval.
using (var image = Image.Load("Animation.gif"))
{
var options = new GifOptions
{
FullFrame = true,
MultiPageOptions = new MultiPageOptions
{
Mode = MultiPageMode.TimeInterval,
TimeInterval = new TimeInterval(0, 400)
}
};
image.Save("PartOfAnimation.gif", options);
}
This example shows how to create a GIF image and save it to a file.
string dir = "c:\\temp\\";
using (Aspose.Imaging.FileFormats.Gif.Blocks.GifFrameBlock firstBlock = new Aspose.Imaging.FileFormats.Gif.Blocks.GifFrameBlock(100, 100))
{
using (Aspose.Imaging.Graphics gr = new Aspose.Imaging.Graphics(firstBlock))
{
using (Aspose.Imaging.Brushes.SolidBrush brush = new Aspose.Imaging.Brushes.SolidBrush(Aspose.Imaging.Color.Red))
{
gr.FillRectangle(brush, firstBlock.Bounds);
}
}
using (Aspose.Imaging.FileFormats.Gif.GifImage gifImage = new Aspose.Imaging.FileFormats.Gif.GifImage(firstBlock))
{
gifImage.Save(dir + "output.gif");
}
}
Create multipage GIF image using single page raster images.
static void Main(string[] args)
{
var frames = LoadFrames("Animation frames").ToArray();
using (var image = new GifImage(new GifFrameBlock(frames[0])))
{
for (var index = 1; index < frames.Length; index++)
{
image.AddPage(frames[index]);
}
image.Save("Multipage.gif");
}
}
private static IEnumerable<RasterImage> LoadFrames(string directory)
{
foreach (var filePath in Directory.GetFiles(directory))
{
yield return (RasterImage)Image.Load(filePath);
}
}
Constructors
GifImage(GifFrameBlock, IColorPalette)
Initiate a new Aspose.Imaging.FileFormats.Gif.GifImage object with specified parameters for thefirst frame and global palette. Start managing GIF images swiftly, ensuringaccurate representation with customizable settings for optimal results.
public GifImage(GifFrameBlock firstFrame, IColorPalette globalPalette)
{
}
Parameters
firstFrame
GifFrameBlock
The first frame to initialize gif image with.
globalPalette
IColorPalette
The global palette to use. Note if both firstFrame’ and
globalPalette’ are null then default global palette is used.
Examples
This example shows how to create a GIF image with a custom palette and save it to a file.
string dir = "c:\\temp\\";
using (Aspose.Imaging.FileFormats.Gif.Blocks.GifFrameBlock firstBlock = new Aspose.Imaging.FileFormats.Gif.Blocks.GifFrameBlock(100, 100))
{
Aspose.Imaging.Graphics gr = new Aspose.Imaging.Graphics(firstBlock);
Aspose.Imaging.Brushes.SolidBrush brush = new Aspose.Imaging.Brushes.SolidBrush(Aspose.Imaging.Color.Red);
gr.FillRectangle(brush, firstBlock.Bounds);
Aspose.Imaging.IColorPalette palette = Aspose.Imaging.ColorPaletteHelper.Create4Bit();
using (Aspose.Imaging.FileFormats.Gif.GifImage gifImage = new Aspose.Imaging.FileFormats.Gif.GifImage(firstBlock, palette))
{
gifImage.Save(dir + "output.gif");
}
}
Exceptions
The firstFrame’ cannot be null
The firstFrame’ already belongs to some other image. Check the Container property.
The globalPalette’ specified should contain entries count equal to power of 2. Minimal palette size is 2, maximal is 256.
GifImage(GifFrameBlock)
Crafting GIF images becomes effortless with the Aspose.Imaging.FileFormats.Gif.GifImageconstructor. With just the firstFrame parameter, it enters in a world of dynamicvisual communication.
public GifImage(GifFrameBlock firstFrame)
{
}
Parameters
firstFrame
GifFrameBlock
The first frame to initialize gif image with.
Examples
This example shows how to create a GIF image and save it to a file.
string dir = "c:\\temp\\";
using (Aspose.Imaging.FileFormats.Gif.Blocks.GifFrameBlock firstBlock = new Aspose.Imaging.FileFormats.Gif.Blocks.GifFrameBlock(100, 100))
{
Aspose.Imaging.Graphics gr = new Aspose.Imaging.Graphics(firstBlock);
Aspose.Imaging.Brushes.SolidBrush brush = new Aspose.Imaging.Brushes.SolidBrush(Aspose.Imaging.Color.Red);
gr.FillRectangle(brush, firstBlock.Bounds);
using (Aspose.Imaging.FileFormats.Gif.GifImage gifImage = new Aspose.Imaging.FileFormats.Gif.GifImage(firstBlock))
{
gifImage.Save(dir + "output.gif");
}
}
The following example shows how to compose an animated GIF image from individual GIF blocks.
string dir = "c:\\temp\\";
using (Aspose.Imaging.FileFormats.Gif.Blocks.GifFrameBlock firstBlock = new Aspose.Imaging.FileFormats.Gif.Blocks.GifFrameBlock(100, 100))
{
using (Aspose.Imaging.FileFormats.Gif.GifImage gifImage = new Aspose.Imaging.FileFormats.Gif.GifImage(firstBlock))
{
Aspose.Imaging.Brushes.SolidBrush brush1 = new Aspose.Imaging.Brushes.SolidBrush(Aspose.Imaging.Color.Red);
Aspose.Imaging.Brushes.SolidBrush brush2 = new Aspose.Imaging.Brushes.SolidBrush(Aspose.Imaging.Color.Black);
for (int angle = 10; angle <= 360; angle += 10)
{
Aspose.Imaging.FileFormats.Gif.Blocks.GifFrameBlock block = new Aspose.Imaging.FileFormats.Gif.Blocks.GifFrameBlock(100, 100);
Aspose.Imaging.Graphics gr = new Aspose.Imaging.Graphics(block);
gr.FillPie(brush1, block.Bounds, 0, angle);
gifImage.AddBlock(block);
}
for (int angle = 10; angle <= 360; angle += 10)
{
Aspose.Imaging.FileFormats.Gif.Blocks.GifFrameBlock block = new Aspose.Imaging.FileFormats.Gif.Blocks.GifFrameBlock(100, 100);
Aspose.Imaging.Graphics gr = new Aspose.Imaging.Graphics(block);
gr.FillPie(brush2, block.Bounds, 0, angle);
gr.FillPie(brush1, block.Bounds, angle, 360 - angle);
gifImage.AddBlock(block);
}
gifImage.Save(dir + "animated_radar.gif");
}
}
Exceptions
The firstFrame’ cannot be null
The firstFrame’ already belongs to some other image. Check the Container property.
The palette specified must contain entries count equal to power of 2. Minimal palette size is 2, maximal is 256.
GifImage(GifFrameBlock, IColorPalette, bool, byte, byte, byte, bool)
Get started effortlessly with the Aspose.Imaging.FileFormats.Gif.GifImage constructor. With thissimple method, you can dive into creating animated GIFs with ease. Just supply thefirstFrame, globalPalette, paletteColorResolution, aspectRatio, and otherparameters, and you’re ready to bring your visuals to life.
public GifImage(
GifFrameBlock firstFrame,
IColorPalette globalPalette,
bool isPaletteSorted,
byte paletteColorResolution,
byte paletteBackgroundColorIndex,
byte aspectRatio,
bool hasTrailer
)
Parameters
firstFrame
GifFrameBlock
The first frame to initialize gif image with.
globalPalette
IColorPalette
The global palette to use. Note if both firstFrame’ and
globalPalette’ are null then default global palette is used.
isPaletteSorted
bool
if set to ’true’ the palette is sorted. Note the parameter is used when globalPalette’ is not null.
paletteColorResolution
byte
The palette color resolution. Note the parameter is used when globalPalette’ is not null.
paletteBackgroundColorIndex
byte
The palette background color index.
aspectRatio
byte
The aspect ratio.
hasTrailer
bool
if set to ’true’ the gif image has trailer otherwise no trailer written at the end of the stream.
Exceptions
The firstFrame’ cannot be null
The firstFrame’ already belongs to some other image. Check the Container property.
The globalPalette’ specified should contain entries count equal to power of 2. Minimal palette size is 2, maximal is 256.
Properties
ActiveFrame
Manage and manipulate frames with this property, enabling smooth navigation andmodification of the active frame within the GIF image.
public GifFrameBlock activeFrame { get; set; }
Property Value
Examples
The following example shows how to remove all blocks from a GIF image.
using (var firstBlock = new Aspose.Imaging.FileFormats.Gif.Blocks.GifFrameBlock(100, 100))
{
using (var gifImage = new Aspose.Imaging.FileFormats.Gif.GifImage(firstBlock))
{
if (gifImage.ActiveFrame != null)
{
Console.WriteLine("Active frame size: {{ Width = {0}, Height = {1}}}", gifImage.ActiveFrame.Width, gifImage.ActiveFrame.Height);
}
else
{
Console.WriteLine("Active frame is not set");
}
Console.WriteLine("Clear all the blocks");
gifImage.ClearBlocks();
if (gifImage.ActiveFrame != null)
{
Console.WriteLine("Active frame size: {{ Width = {0}, Height = {1}}}", gifImage.ActiveFrame.Width, gifImage.ActiveFrame.Height);
}
else
{
Console.WriteLine("Active frame is not set");
}
}
}
BackgroundColor
Manage the background color of the GIF image with this property. You can set orretrieve the background color to ensure consistency and enhance visual appeal.
public override Color BackgroundColor
{
get;
set;
}
Property Value
BackgroundColorIndex
Control the background color index of the GIF image using this property. Set orretrieve the index to maintain consistency or achieve desired visual effects.
public byte BackgroundColorIndex
{
get;
set;
}
Property Value
Blocks
Gain access to the GIF blocks seamlessly with this property, facilitating easyretrieval and manipulation of the image’s underlying data structures.
public IGifBlock[] Blocks
{
get;
}
Property Value
IGifBlock []
FileFormat
Retrieve the file format effortlessly with this property. It’s your go-to sourcefor identifying the format of your files. Seamlessly integrated into your workflow,it provides vital information without any hassle.
public override FileFormat
get {
}
Property Value
HasBackgroundColor
This property determines whether the GIF image contains a background color. Iftrue, it indicates that the image includes a background color.
public override bool HasBackgroundColor
{
get;
}
Property Value
HasTrailer
Manage the presence of a trailer in your GIF files with this property. Whether youneed to check if a trailer exists or set its presence, this property simplifies theprocess. Keep your GIF files structured and compliant with this intuitive feature.
public bool HasTrailer
{
get;
set;
}
Property Value
HasTransparentColor
Determine whether the active frame of the GIF image includes a transparent color.This property provides a convenient way to check for transparency within the image.
public override bool HasTransparentColor
{
get;
set;
}
Property Value
ImageOpacity
Retrieve the opacity of the active frame within the image, offering insight intoits transparency level. This property is particularly useful for understanding thedegree of transparency or opaqueness of the active frame in the image.
public override float ImageOpacity
{
get;
}
Property Value
IsInterlaced
Determines if the image is interlaced, impacting its display during loading. Thisproperty offers insight into the image’s rendering behavior, essential foroptimizing loading strategies and enhancing overall viewing experience.
public bool IsInterlaced
{
get;
}
Property Value
IsPaletteSorted
Control the sorting of the palette in your GIF images using this property. Whetheryou need to check if the palette is sorted or set the sorting behavior, thisproperty provides a straightforward way to manage the palette organization in yourGIF files.
public bool IsPaletteSorted
{
get;
set;
}
Property Value
LoopsCount
Retrieve the loop count effortlessly with this property. If your GIF image includesloop information, this property gives you quick access to the loop count, enablingyou to seamlessly manage looping behavior in your GIF files.
public int LoopsCount
{
get;
set;
}
Property Value
PageCount
Retrieve the total number of pages contained within the image with thisstraightforward property. Ideal for quickly assessing the extent of the image content.
public override int PageCount
{
get;
}
Property Value
Pages
Gain access to the pages within the image through this convenient property,allowing seamless navigation and manipulation of individual pages as needed.
public override Image[] Pages
{
get;
}
Property Value
Image []
PaletteColorResolutionBits
Manage the palette color resolution of your GIF images with this property. Adjustthe number of bits used to represent colors in the palette, providing fine controlover color depth and image quality.
public byte PaletteColorResolutionBits
{
get;
set;
}
Property Value
PixelAspectRatio
Manage the pixel aspect ratio of the GIF image with this property. Set or retrievethe aspect ratio to ensure accurate rendering and maintain visual fidelity.
public byte PixelAspectRatio
{
get;
set;
}
Property Value
TransparentColor
Retrieve the transparent color of the active frame in the GIF image. This propertyallows you to access the specific color that has been designated as transparentwithin the currently active frame.
public override Color TransparentColor
{
get;
}
Property Value
XmpData
Manage XMP metadata with this property. Whether you’re retrieving existing metadataor updating it with new information, this property streamlines the process. Keepyour metadata organized and accessible, ensuring that your files contain therelevant information they need.
public override XmpPacketWrapper XmpData
{
get;
set;
}
Property Value
Methods
AddBlock(IGifBlock)
Adding a new GIF block allows you to include additional data within the image.This method enables you to append custom blocks to the GIF image, which cancontain various types of information.
public void AddBlock(IGifBlock block)
{
}
Parameters
block
IGifBlock
The GIF block to add.
Examples
The following example shows how to compose an animated GIF image from individual GIF blocks.
string dir = "c:\\temp\\";
using (Aspose.Imaging.FileFormats.Gif.Blocks.GifFrameBlock firstBlock = new Aspose.Imaging.FileFormats.Gif.Blocks.GifFrameBlock(100, 100))
{
using (Aspose.Imaging.FileFormats.Gif.GifImage gifImage = new Aspose.Imaging.FileFormats.Gif.GifImage(firstBlock))
{
Aspose.Imaging.Brushes.SolidBrush brush1 = new Aspose.Imaging.Brushes.SolidBrush(Aspose.Imaging.Color.Red);
Aspose.Imaging.Brushes.SolidBrush brush2 = new Aspose.Imaging.Brushes.SolidBrush(Aspose.Imaging.Color.Black);
for (int angle = 10; angle <= 360; angle += 10)
{
Aspose.Imaging.FileFormats.Gif.Blocks.GifFrameBlock block = new Aspose.Imaging.FileFormats.Gif.Blocks.GifFrameBlock(100, 100);
Aspose.Imaging.Graphics gr = new Aspose.Imaging.Graphics(block);
gr.FillPie(brush1, block.Bounds, 0, angle);
gifImage.AddBlock(block);
}
for (int angle = 10; angle <= 360; angle += 10)
{
Aspose.Imaging.FileFormats.Gif.Blocks.GifFrameBlock block = new Aspose.Imaging.FileFormats.Gif.Blocks.GifFrameBlock(100, 100);
Aspose.Imaging.Graphics gr = new Aspose.Imaging.Graphics(block);
gr.FillPie(brush2, block.Bounds, 0, angle);
gr.FillPie(brush1, block.Bounds, angle, 360 - angle);
gifImage.AddBlock(block);
}
gifImage.Save(dir + "animated_radar.gif");
}
}
AddPage(RasterImage)
Incorporate a new page seamlessly into the existing image, enhancing its contentand expanding its scope. This method augment image collections with additionalcontent, fostering creativity and flexibility in image management and composition.
public void AddPage(RasterImage page)
{
}
Parameters
page
RasterImage
The page to add.
Examples
Create multipage GIF image using single page raster images.
static void Main(string[] args)
{
var frames = LoadFrames("Animation frames").ToArray();
using (var image = new GifImage(new GifFrameBlock(frames[0])))
{
for (var index = 1; index < frames.Length; index++)
{
image.AddPage(frames[index]);
}
image.Save("Multipage.gif");
}
}
private static IEnumerable<RasterImage> LoadFrames(string directory)
{
foreach (var filePath in Directory.GetFiles(directory))
{
yield return (RasterImage)Image.Load(filePath);
}
}
Exceptions
page’ is null.
AdjustBrightness(int)
Adjusts the brightness of the image according to the specifiedbrightness’ parameter. This method modifies the brightness ofthe entire image uniformly, enhancing or reducing the overall luminance to achievethe desired effect.
public override void AdjustBrightness(int brightness)
{
}
Parameters
brightness
int
Brightness value.
Examples
The following example performs brightness correction of a GIF image.
string dir = "c:\\temp\\";
using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.gif"))
{
var gifImage = (Aspose.Imaging.FileFormats.Gif.GifImage)image;
gifImage.AdjustBrightness(50);
gifImage.Save(dir + "sample.AdjustBrightness.png", new Aspose.Imaging.ImageOptions.PngOptions());
}
AdjustContrast(float)
Adjusts the contrast of the image, enhancing or reducing the difference inbrightness between pixels. This method modifies the image’s overall tonal range,making darker areas darker and brighter areas brighter to improve visual clarityand detail.
public override void AdjustContrast(float contrast)
{
}
Parameters
contrast
float
Contrast value (in range [-100; 100])
Examples
The following example performs contrast correction of a GIF image.
string dir = "c:\\temp\\";
using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.gif"))
{
Aspose.Imaging.FileFormats.Gif.GifImage gifImage = (Aspose.Imaging.FileFormats.Gif.GifImage)image;
gifImage.AdjustContrast(50f);
gifImage.Save(dir + "sample.AdjustContrast.png", new Aspose.Imaging.ImageOptions.PngOptions());
}
Exceptions
Can’t change contrast. Frame index: " + frameIndex
AdjustGamma(float)
Enhance image quality by applying gamma correction. This method adjusts the colorgamma of the image to achieve optimal visual clarity. It modifies the gamma valueof each pixel, resulting in improved color rendition and overall image appearance.
public override void AdjustGamma(float gamma)
{
}
Parameters
gamma
float
Gamma for red, green and blue channels coefficient
Examples
The following example performs gamma-correction of a GIF image.
string dir = "c:\\temp\\";
using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.gif"))
{
Aspose.Imaging.FileFormats.Gif.GifImage gifImage = (Aspose.Imaging.FileFormats.Gif.GifImage)image;
gifImage.AdjustGamma(2.5f);
gifImage.Save(dir + "sample.AdjustGamma.png", new Aspose.Imaging.ImageOptions.PngOptions());
}
AdjustGamma(float, float, float)
Gamma-correction of an image applies a nonlinear adjustment to the pixel values,enhancing or reducing brightness based on the specified coefficients for the red,green, and blue channels. This method helps to fine-tune the color balance andluminance of the image, improving its overall appearance and visual quality.
public override void AdjustGamma(
float gammaRed,
float gammaGreen,
float gammaBlue
)
This is the reformatted C# code with proper indentation and spacing according to standard C# conventions.
Parameters
gammaRed
float
Gamma for red channel coefficient
gammaGreen
float
Gamma for green channel coefficient
gammaBlue
float
Gamma for blue channel coefficient
Examples
The following example performs gamma-correction of a GIF image applying different coefficients for color components.
string dir = "c:\\temp\\";
using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.gif"))
{
Aspose.Imaging.FileFormats.Gif.GifImage gifImage = (Aspose.Imaging.FileFormats.Gif.GifImage)image;
gifImage.AdjustGamma(1.5f, 2.5f, 3.5f);
gifImage.Save(dir + "sample.AdjustGamma.png", new Aspose.Imaging.ImageOptions.PngOptions());
}
BinarizeBradley(double)
Binarization of an image using Bradley’s adaptive thresholding algorithm withintegral image thresholding is a method for converting a grayscale image into abinary image. This algorithm calculates a local threshold for each pixel based onthe average intensity of the surrounding pixels within a specified window. Byadaptively adjusting the threshold based on local pixel intensities, Bradley’smethod is effective at handling variations in lighting and contrast across the image.
public override void BinarizeBradley(double brightnessDifference)
{
}
Parameters
brightnessDifference
double
The brightness difference between pixel and the average of an s x s window of pixels centered around this pixel.
BinarizeFixed(byte)
Binarization of an image with a predefined threshold converts a grayscale or colorimage into a binary image, where each pixel is classified as either black or whitebased on whether its intensity value exceeds a specified threshold.
public override void BinarizeFixed(byte threshold)
{
}
I've reformatted your provided C# code, ensuring proper indentation and general readability improvements. As per the requirements specified, I did not modify or remove any code comments nor make any changes to variable names, method names, class names, types, namespaces, or library-specific knowledge.
Parameters
threshold
byte
Threshold value. If corresponding gray value of a pixel is greater than threshold, a value of 255 will be assigned to it, 0 otherwise.
Examples
The following example binarizes a GIF image with the predefined threshold. Binarized images contain only 2 colors - black and white.
string dir = "c:\\temp\\";
using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.gif"))
{
var djvuImage = (Aspose.Imaging.FileFormats.Gif.GifImage)image;
djvuImage.BinarizeFixed(127);
djvuImage.Save(dir + "sample.BinarizeFixed.png", new Aspose.Imaging.ImageOptions.PngOptions());
}
BinarizeOtsu()
Binarization of an image with Otsu thresholding is a method used to automaticallydetermine the optimal threshold value for converting a grayscale image into abinary image. The Otsu thresholding algorithm calculates the threshold thatminimizes the intra-class variance of the pixel intensities in the two resultingclasses (foreground and background). This technique is particularly useful whenthe optimal threshold value is unknown and needs to be determined adaptively basedon the image’s histogram.
public override void BinarizeOtsu()
{
}
Examples
The following example binarizes a GIF image with Otsu thresholding. Binarized images contain only 2 colors - black and white.
string dir = "c:\\temp\\";
using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.gif"))
{
var gifImage = (Aspose.Imaging.FileFormats.Gif.GifImage)image;
gifImage.BinarizeOtsu();
gifImage.Save(dir + "sample.BinarizeOtsu.png", new Aspose.Imaging.ImageOptions.PngOptions());
}
ClearBlocks()
Clearing all the GIF blocks removes any existing data stored within the image.This operation effectively resets the image to an empty state, removing anypreviously added blocks. Use this method when you need to start fresh with a cleanslate for creating or modifying a GIF image.
public void ClearBlocks()
{
}
In this case, since there is only one line of code and it already adheres to standard C# conventions for spacing and indentation, no reformatting was necessary.
Examples
The following example shows how to remove all blocks from a GIF image.
using (Aspose.Imaging.FileFormats.Gif.Blocks.GifFrameBlock firstBlock = new Aspose.Imaging.FileFormats.Gif.Blocks.GifFrameBlock(100, 100))
{
using (Aspose.Imaging.FileFormats.Gif.GifImage gifImage = new Aspose.Imaging.FileFormats.Gif.GifImage(firstBlock))
{
if (gifImage.ActiveFrame != null)
{
System.Console.WriteLine("Active frame size: {{0}}", gifImage.ActiveFrame.Size);
}
else
{
System.Console.WriteLine("Active frame is not set");
}
System.Console.WriteLine("Clear all the blocks");
gifImage.ClearBlocks();
if (gifImage.ActiveFrame != null)
{
System.Console.WriteLine("Active frame size: {{0}}", gifImage.ActiveFrame.Size);
}
else
{
System.Console.WriteLine("Active frame is not set");
}
}
}
Crop(Rectangle)
Crop the image using a specified rectangle area. This operation removes the outerportion of the image, leaving only the selected region defined by the rectangle.
public override void
Crop(Rectangle rectangle)
{
}
Parameters
rectangle
Rectangle
The rectangle.
Examples
The following example crops a GIF image. The cropping area is be specified via Aspose.Imaging.Rectangle.
string dir = "c:\\temp\\";
using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.gif"))
{
var gifImage = (Aspose.Imaging.FileFormats.Gif.GifImage)image;
Aspose.Imaging.Rectangle area = new Aspose.Imaging.Rectangle(gifImage.Width / 4, gifImage.Height / 4, gifImage.Width / 2, gifImage.Height / 2);
gifImage.Crop(area);
gifImage.Save(dir + "sample.Crop.png", new Aspose.Imaging.ImageOptions.PngOptions());
}
Dither(DitheringMethod, int, IColorPalette)
Apply dithering to the current image. This process enhances image quality byreducing color banding and improving color transitions, resulting in a smootherappearance.
public override void
Dither(
DitheringMethod ditheringMethod,
int bitsCount,
IColorPalette customPalette)
{
}
Parameters
ditheringMethod
DitheringMethod
The dithering method.
bitsCount
int
The final bits count for dithering.
customPalette
IColorPalette
The custom palette for dithering.
Examples
The following example loads a GIF image and performs threshold and floyd dithering using different palette depth.
string dir = "c:\\temp\\";
using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.gif"))
{
Aspose.Imaging.FileFormats.Gif.GifImage gifImage = (Aspose.Imaging.FileFormats.Gif.GifImage)image;
gifImage.Dither(Aspose.Imaging.DitheringMethod.ThresholdDithering, 4, null);
gifImage.Save(dir + "sample.ThresholdDithering4.png", new Aspose.Imaging.ImageOptions.PngOptions());
}
using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.gif"))
{
Aspose.Imaging.FileFormats.Gif.GifImage gifImage = (Aspose.Imaging.FileFormats.Gif.GifImage)image;
gifImage.Dither(Aspose.Imaging.DitheringMethod.FloydSteinbergDithering, 1, null);
gifImage.Save(dir + "sample.FloydSteinbergDithering1.png", new Aspose.Imaging.ImageOptions.PngOptions());
}
Filter(Rectangle, FilterOptionsBase)
Apply a specific filter to the designated area of the image, enhancing its visualquality or altering its appearance as desired. This method selectively processespixels within the defined rectangle, allowing for targeted adjustments to be madewhile preserving the integrity of the surrounding image data.
public override void
Filter(Rectangle rectangle, FilterOptionsBase options)
{
}
Parameters
rectangle
Rectangle
The rectangle.
options
FilterOptionsBase
The options.
Examples
The following example applies various types of filters to a GIF image.
string dir = "c:\\temp\\";
using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.gif"))
{
Aspose.Imaging.FileFormats.Gif.GifImage gifImage = (Aspose.Imaging.FileFormats.Gif.GifImage)image;
gifImage.Filter(gifImage.Bounds, new Aspose.Imaging.ImageFilters.FilterOptions.MedianFilterOptions(5));
gifImage.Save(dir + "sample.MedianFilter.png", new Aspose.Imaging.ImageOptions.PngOptions());
}
using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.gif"))
{
Aspose.Imaging.FileFormats.Gif.GifImage gifImage = (Aspose.Imaging.FileFormats.Gif.GifImage)image;
gifImage.Filter(gifImage.Bounds, new Aspose.Imaging.ImageFilters.FilterOptions.BilateralSmoothingFilterOptions(5));
gifImage.Save(dir + "sample.BilateralSmoothingFilter.png", new Aspose.Imaging.ImageOptions.PngOptions());
}
using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.gif"))
{
Aspose.Imaging.FileFormats.Gif.GifImage gifImage = (Aspose.Imaging.FileFormats.Gif.GifImage)image;
gifImage.Filter(gifImage.Bounds, new Aspose.Imaging.ImageFilters.FilterOptions.GaussianBlurFilterOptions(5, 4.0));
gifImage.Save(dir + "sample.GaussianBlurFilter.png", new Aspose.Imaging.ImageOptions.PngOptions());
}
using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.gif"))
{
Aspose.Imaging.FileFormats.Gif.GifImage gifImage = (Aspose.Imaging.FileFormats.Gif.GifImage)image;
gifImage.Filter(gifImage.Bounds, new Aspose.Imaging.ImageFilters.FilterOptions.GaussWienerFilterOptions(5, 4.0));
gifImage.Save(dir + "sample.GaussWienerFilter.png", new Aspose.Imaging.ImageOptions.PngOptions());
}
using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.gif"))
{
Aspose.Imaging.FileFormats.Gif.GifImage gifImage = (Aspose.Imaging.FileFormats.Gif.GifImage)image;
gifImage.Filter(gifImage.Bounds, new Aspose.Imaging.ImageFilters.FilterOptions.MotionWienerFilterOptions(10, 1.0, 90.0));
gifImage.Save(dir + "sample.MotionWienerFilter.png", new Aspose.Imaging.ImageOptions.PngOptions());
}
using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.gif"))
{
Aspose.Imaging.FileFormats.Gif.GifImage gifImage = (Aspose.Imaging.FileFormats.Gif.GifImage)image;
gifImage.Filter(gifImage.Bounds, new Aspose.Imaging.ImageFilters.FilterOptions.SharpenFilterOptions(5, 4.0));
gifImage.Save(dir + "sample.SharpenFilter.png", new Aspose.Imaging.ImageOptions.PngOptions());
}
GetOriginalOptions()
Retrieve the original file settings-based options, crucial for maintaining fidelityand consistency in image processing and manipulation. This method allows seamlessintegration of file-specific parameters into subsequent operations, ensuringaccurate rendition and adherence to the image’s inherent characteristics.This can be helpful to keep bit-depth and other parameters of the original image unchanged.For example, if we load a black-white PNG image with 1 bit per pixel and then save it using theAspose.Imaging.DataStreamSupporter.Save(System.String) method, the output PNG image with 8-bit per pixel will be produced.To avoid it and save PNG image with 1-bit per pixel, use this method to get corresponding saving options and pass themto the Aspose.Imaging.Image.Save(System.String,Aspose.Imaging.ImageOptionsBase) method as the second parameter.
public override ImageOptionsBase GetOriginalOptions()
{
}
Returns
The options based on the original file settings.
Grayscale()
The transformation of an image to its grayscale representation converts the colorimage into a grayscale version by removing color information while preservingluminance. This process simplifies the image to shades of gray, making it suitablefor various applications such as printing, document processing, and grayscaleanalysis.
public override void Grayscale()
{
}
Examples
The following example transforms a colored GIF image to its grayscale representation. Grayscale images are composed exclusively of shades of gray and carry only intensity information.
string dir = "c:\\temp\\";
using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.gif"))
{
var gifImage = (Aspose.Imaging.FileFormats.Gif.GifImage)image;
gifImage.Grayscale();
gifImage.Save(dir + "sample.Grayscale.png", new Aspose.Imaging.ImageOptions.PngOptions());
}
InsertBlock(int, IGifBlock)
Inserting a new GIF block allows you to add custom data at a specific positionwithin the image. This method enables you to place custom blocks at a desiredlocation in the GIF image, providing flexibility in organizing and structuring theimage data.
public void InsertBlock(int index, IGifBlock block)
{
}
Parameters
index
int
The zero-based element, at which block will be inserted.
block
IGifBlock
The GIF block to add.
OnPaletteChanged(IColorPalette, IColorPalette)
Called when palette is changed.
protected override void OnPaletteChanged(
IColorPalette oldPalette,
IColorPalette newPalette
)
{
}
Parameters
oldPalette
IColorPalette
The old palette.
newPalette
IColorPalette
The new palette.
OnPaletteChanging(IColorPalette, IColorPalette)
Called when palette is changing.
protected override void OnPaletteChanging(
IColorPalette oldPalette,
IColorPalette newPalette)
{
}
Parameters
oldPalette
IColorPalette
The old palette.
newPalette
IColorPalette
The new palette.
OrderBlocks()
Ordering the GIF blocks according to the GIF specification ensures proper GIFlayout and compliance with the standard. This process involves arranging theblocks in the correct sequence as defined by the specification. Additionally, itmay involve removing certain Aspose.Imaging.FileFormats.Gif.Blocks.GifGraphicsControlBlock instances thatare not necessary for the final layout. By adhering to the GIF specification, theresulting image will be correctly structured and compatible with GIF viewingapplications.
public void OrderBlocks()
{
}
RemoveBlock(IGifBlock)
Removing a GIF block removes specific data from the image, offering the ability toclean up or modify the image structure. This method enables you to remove unwantedor unnecessary blocks, optimizing the GIF image for efficient storage. Use thisfunctionality to eliminate outdated information from the image while preservingits integrity and quality.
public void RemoveBlock(IGifBlock block)
{
}
Parameters
block
IGifBlock
The block to remove.
Remarks
Note: do not forget to Dispose the block if you will not add it to some other GifImage.
Resize(int, int, ResizeType)
Resizes this Aspose.Imaging.Image instance.
public override void
Resize(
int newWidth,
int newHeight,
ResizeType resizeType)
{
}
Parameters
newWidth
int
The new width.
newHeight
int
The new height.
resizeType
ResizeType
The resize type.
Examples
This example loads a GIF image and resizes it using various resizing methods.
string dir = "c:\\temp\\";
using (Aspose.Imaging.FileFormats.Gif.GifImage image = (Aspose.Imaging.FileFormats.Gif.GifImage)Aspose.Imaging.Image.Load(dir + "sample.gif"))
{
image.Resize(image.Width * 2, image.Height * 2, Aspose.Imaging.ResizeType.NearestNeighbourResample);
image.Save(dir + "upsample.nearestneighbour.gif");
}
using (Aspose.Imaging.FileFormats.Gif.GifImage image = (Aspose.Imaging.FileFormats.Gif.GifImage)Aspose.Imaging.Image.Load(dir + "sample.gif"))
{
image.Resize(image.Width / 2, image.Height / 2, Aspose.Imaging.ResizeType.NearestNeighbourResample);
image.Save(dir + "downsample.nearestneighbour.gif");
}
using (Aspose.Imaging.FileFormats.Gif.GifImage image = (Aspose.Imaging.FileFormats.Gif.GifImage)Aspose.Imaging.Image.Load(dir + "sample.gif"))
{
image.Resize(image.Width * 2, image.Height * 2, Aspose.Imaging.ResizeType.BilinearResample);
image.Save(dir + "upsample.bilinear.gif");
}
using (Aspose.Imaging.FileFormats.Gif.GifImage image = (Aspose.Imaging.FileFormats.Gif.GifImage)Aspose.Imaging.Image.Load(dir + "sample.gif"))
{
image.Resize(image.Width / 2, image.Height / 2, Aspose.Imaging.ResizeType.BilinearResample);
image.Save(dir + "downsample.bilinear.gif");
}
Resize(int, int, ImageResizeSettings)
Resizes this Aspose.Imaging.Image instance.
public override void Resize(
int newWidth,
int newHeight,
ImageResizeSettings settings)
{
}
Parameters
newWidth
int
The new width.
newHeight
int
The new height.
settings
ImageResizeSettings
The settings.
Examples
This example loads a GIF image and resizes it using various resizing settings.
string dir = "c:\\temp\\";
Aspose.Imaging.ImageResizeSettings resizeSettings = new Aspose.Imaging.ImageResizeSettings();
resizeSettings.Mode = Aspose.Imaging.ResizeType.AdaptiveResample;
resizeSettings.FilterType = Aspose.Imaging.ImageFilterType.SmallRectangular;
resizeSettings.EntriesCount = 256;
resizeSettings.ColorQuantizationMethod = Aspose.Imaging.ColorQuantizationMethod.None;
resizeSettings.ColorCompareMethod = Aspose.Imaging.ColorCompareMethod.Euclidian;
using (Aspose.Imaging.Image image = (Aspose.Imaging.Image)Aspose.Imaging.Image.Load(dir + "sample.gif"))
{
Aspose.Imaging.FileFormats.Gif.GifImage gifImage = (Aspose.Imaging.FileFormats.Gif.GifImage)image;
gifImage.Resize(image.Width / 2, image.Height / 2, resizeSettings);
gifImage.Save(dir + "downsample.adaptive.png", new Aspose.Imaging.ImageOptions.PngOptions());
}
ResizeFullFrame(int, int, ResizeType)
Resizing of the image while taking into account the full frames for each page in aGIF, thus preventing potential artifacts from appearing. This method is essentialto maintain the integrity and quality of the image, especially when dealing withanimated GIFs or sequences of frames.
public void ResizeFullFrame(int newWidth, int newHeight, ResizeType resizeType)
{
}
Parameters
newWidth
int
The new width.
newHeight
int
The new height.
resizeType
ResizeType
The resize type.
ResizeProportional(int, int, ResizeType)
Proportional resizing maintains the aspect ratio of the image while adjusting itssize, ensuring that the image does not appear stretched or distorted. This methodresizes the image proportionally, scaling both the width and height by the same factor.The proportional resize will resize each frame according to the ratio of newWidth’/width and
newHeight’/height.
public void ResizeProportional(
int newWidth,
int newHeight,
ResizeType resizeType)
{
}
Parameters
newWidth
int
The new width.
newHeight
int
The new height.
resizeType
ResizeType
The resize type.
Rotate(float, bool, Color)
This method rotates the image around its center point. By specifying the rotationangle, you can rotate the image clockwise or counterclockwise to achieve thedesired orientation. This rotation helps adjust the image’s presentation oralignment without distorting its content.
public override void Rotate(
float angle,
bool resizeProportionally,
Color backgroundColor
)
{
}
Parameters
angle
float
The rotate angle in degrees. Positive values will rotate clockwise.
resizeProportionally
bool
if set to ’true’ you will have your image size changedaccording to rotated rectangle (corner points) projections in othercase that leaves dimensions untouched and onlyinternal image contents are rotated.
backgroundColor
Color
Color of the background.
RotateFlip(RotateFlipType)
Perform rotation, flipping, or both on the active frame exclusively. This operationapplies transformations solely to the currently active frame of the image,preserving the integrity of other frames in the sequence.
public override void RotateFlip(RotateFlipType rotateFlipType)
{
}
Parameters
rotateFlipType
RotateFlipType
The rotate flip type.
Examples
This example loads a GIF image, rotates it by 90 degrees clockwise and optionally flips the image horizontally and(or) vertically.
string dir = "c:\\temp\\";
Aspose.Imaging.RotateFlipType[] rotateFlipTypes = new Aspose.Imaging.RotateFlipType[]
{
Aspose.Imaging.RotateFlipType.Rotate90FlipNone,
Aspose.Imaging.RotateFlipType.Rotate90FlipX,
Aspose.Imaging.RotateFlipType.Rotate90FlipXY,
Aspose.Imaging.RotateFlipType.Rotate90FlipY
};
foreach (Aspose.Imaging.RotateFlipType rotateFlipType in rotateFlipTypes)
{
using (Aspose.Imaging.FileFormats.Gif.GifImage image = (Aspose.Imaging.FileFormats.Gif.GifImage)Aspose.Imaging.Image.Load(dir + "sample.gif"))
{
image.RotateFlip(rotateFlipType);
image.Save(dir + "sample." + rotateFlipType + ".png", new Aspose.Imaging.ImageOptions.PngOptions());
}
}
SaveData(Stream)
Saves the data.
protected override void SaveData(Stream stream)
{
}
Parameters
stream
Stream
The stream to save data to.
SetFrameTime(ushort)
Adjusts the duration of each frame in milliseconds, ensuring consistent timingthroughout the image sequence. This method uniformly sets the display time forevery frame, allowing for precise control over animation speed.Changing this value will reset delay for all frames.
public void SetFrameTime(ushort time)
{
}
Parameters
time
ushort
The time of frame duration in milliseconds.
UpdateDimensions(int, int)
Updates the image dimensions.
protected override void UpdateDimensions(
int newWidth,
int newHeight
)
{
}
Parameters
newWidth
int
The new image width.
newHeight
int
The new image height.