Class GifFrameBlock
Namespace: Aspose.Imaging.FileFormats.Gif.Blocks
Assembly: Aspose.Imaging.dll (25.2.0)
GIF frame class.
[JsonObject(MemberSerialization.OptIn)]
public sealed class GifFrameBlock : RasterCachedImage, IDisposable, IObjectWithBounds, IRasterImageArgb32PixelLoader, IRasterImageRawDataLoader, IHasXmpData, IHasMetadata, IGifBlock, IAnimationFrame
Inheritance
object ← DisposableObject ← DataStreamSupporter ← Image ← RasterImage ← RasterCachedImage ← GifFrameBlock
Implements
IDisposable, IObjectWithBounds, IRasterImageArgb32PixelLoader, IRasterImageRawDataLoader, IHasXmpData, IHasMetadata, IGifBlock, IAnimationFrame
Inherited Members
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.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.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()
Constructors
GifFrameBlock(ushort, ushort)
Initializes a new instance of the Aspose.Imaging.FileFormats.Gif.Blocks.GifFrameBlock class.
public GifFrameBlock(ushort width, ushort height)
Parameters
width
ushort
The image width.
height
ushort
The image height.
Examples
This example shows how to create a GIF image and save it to a file.```csharp [C#]
string dir = "c:\\temp\\";
// Create a GIF Frame block of 100x100 px.
using (Aspose.Imaging.FileFormats.Gif.Blocks.GifFrameBlock firstBlock = new Aspose.Imaging.FileFormats.Gif.Blocks.GifFrameBlock(100, 100))
{
// Fill the entire block in red.
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");
}
}
This example shows how to create a GIF image with a custom palette and save it to a file.```csharp
[C#]
string dir = "c:\\temp\\";
// Create a GIF Frame block of 100x100 px.
using (Aspose.Imaging.FileFormats.Gif.Blocks.GifFrameBlock firstBlock = new Aspose.Imaging.FileFormats.Gif.Blocks.GifFrameBlock(100, 100))
{
// Fill the entire block in red.
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);
// Use 4-bit palette to reduce the image size. The quality can get worse.
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");
}
}
The following example shows how to compose an animated GIF image from individual GIF blocks.```csharp [C#]
string dir = "c:\\temp\\";
// Create a GIF image 100 x 100 px.
// The first block is fully black by default.
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))
{
// The first circle is red
Aspose.Imaging.Brushes.SolidBrush brush1 = new Aspose.Imaging.Brushes.SolidBrush(Aspose.Imaging.Color.Red);
// The second circle is black
Aspose.Imaging.Brushes.SolidBrush brush2 = new Aspose.Imaging.Brushes.SolidBrush(Aspose.Imaging.Color.Black);
// Gradually inscrease the angle of the red arc shape.
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);
}
// Gradually inscrease the angle of the black arc and wipe out the red arc.
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");
}
### <a id="Aspose_Imaging_FileFormats_Gif_Blocks_GifFrameBlock__ctor_System_UInt16_System_UInt16_System_UInt16_System_UInt16_"></a> GifFrameBlock\(ushort, ushort, ushort, ushort\)
Initializes a new instance of the Aspose.Imaging.FileFormats.Gif.Blocks.GifFrameBlock class.
```csharp
public GifFrameBlock(ushort left, ushort top, ushort width, ushort height)
Parameters
left
ushort
The left image position.
top
ushort
The top image position.
width
ushort
The image width.
height
ushort
The image height.
GifFrameBlock(ushort, ushort, ushort, ushort, IColorPalette, bool, bool, byte)
Initializes a new instance of the Aspose.Imaging.FileFormats.Gif.Blocks.GifFrameBlock class.
public GifFrameBlock(ushort left, ushort top, ushort width, ushort height, IColorPalette colorPalette, bool isPaletteSorted, bool isGifFrameInterlaced, byte bitsPerPixel)
Parameters
left
ushort
The left image position.
top
ushort
The top image position.
width
ushort
The image Width.
height
ushort
The image Height.
colorPalette
IColorPalette
The color palette.
isPaletteSorted
bool
if set to true
the color palette is sorted.
isGifFrameInterlaced
bool
if set to true
the GIF frame is interlaced.
bitsPerPixel
byte
The bits per pixel.
GifFrameBlock(RasterImage)
Initializes a new instance of the Aspose.Imaging.FileFormats.Gif.Blocks.GifFrameBlock class.
public GifFrameBlock(RasterImage image)
Parameters
image
RasterImage
The image to initialize frame pixel and palette data with.
GifFrameBlock(RasterImage, ushort, ushort)
Initializes a new instance of the Aspose.Imaging.FileFormats.Gif.Blocks.GifFrameBlock class.
public GifFrameBlock(RasterImage image, ushort left, ushort top)
Parameters
image
RasterImage
The image to initialize frame pixel and palette data with.
left
ushort
The left image position.
top
ushort
The top image position.
GifFrameBlock(RasterImage, ushort, ushort, bool, bool, byte)
Initializes a new instance of the Aspose.Imaging.FileFormats.Gif.Blocks.GifFrameBlock class.
public GifFrameBlock(RasterImage image, ushort left, ushort top, bool isPaletteSorted, bool isGifFrameInterlaced, byte lzwCodeSize)
Parameters
image
RasterImage
The image to initialize frame pixel and palette data with.
left
ushort
The left image position.
top
ushort
The top image position.
isPaletteSorted
bool
if set to true
the color palette is sorted.
isGifFrameInterlaced
bool
if set to true
the GIF frame is interlaced.
lzwCodeSize
byte
The bits per pixel.
GifFrameBlock(Stream)
Initializes a new instance of the Aspose.Imaging.FileFormats.Gif.Blocks.GifFrameBlock class.
public GifFrameBlock(Stream stream)
Parameters
stream
Stream
The stream to load an image from and initialize frame pixel and palette data with.
GifFrameBlock(Stream, ushort, ushort)
Initializes a new instance of the Aspose.Imaging.FileFormats.Gif.Blocks.GifFrameBlock class.
public GifFrameBlock(Stream stream, ushort left, ushort top)
Parameters
stream
Stream
The stream to load an image from and initialize frame pixel and palette data with.
left
ushort
The left image position.
top
ushort
The top image position.
GifFrameBlock(Stream, ushort, ushort, bool, bool, byte)
Initializes a new instance of the Aspose.Imaging.FileFormats.Gif.Blocks.GifFrameBlock class.
public GifFrameBlock(Stream stream, ushort left, ushort top, bool isPaletteSorted, bool isGifFrameInterlaced, byte lzwCodeSize)
Parameters
stream
Stream
The stream to load an image from and initialize frame pixel and palette data with.
left
ushort
The left image position.
top
ushort
The top image position.
isPaletteSorted
bool
if set to true
the color palette is sorted.
isGifFrameInterlaced
bool
if set to true
the GIF frame is interlaced.
lzwCodeSize
byte
The bits per pixel.
GifFrameBlock(string)
Initializes a new instance of the Aspose.Imaging.FileFormats.Gif.Blocks.GifFrameBlock class.
public GifFrameBlock(string path)
Parameters
path
string
The path to load an image from and initialize frame pixel and palette data with.
GifFrameBlock(string, ushort, ushort)
Initializes a new instance of the Aspose.Imaging.FileFormats.Gif.Blocks.GifFrameBlock class.
public GifFrameBlock(string path, ushort left, ushort top)
Parameters
path
string
The path to load an image from and initialize frame pixel and palette data with.
left
ushort
The left image position.
top
ushort
The top image position.
GifFrameBlock(string, ushort, ushort, bool, bool, byte)
Initializes a new instance of the Aspose.Imaging.FileFormats.Gif.Blocks.GifFrameBlock class.
public GifFrameBlock(string path, ushort left, ushort top, bool isPaletteSorted, bool isGifFrameInterlaced, byte lzwCodeSize)
Parameters
path
string
The path to load an image from and initialize frame pixel and palette data with.
left
ushort
The left image position.
top
ushort
The top image position.
isPaletteSorted
bool
if set to true
the color palette is sorted.
isGifFrameInterlaced
bool
if set to true
the GIF frame is interlaced.
lzwCodeSize
byte
The bits per pixel.
Fields
ExtensionLabel
Block extension label.
public const int ExtensionLabel = 44
Field Value
ImageDescriptorSize
The image descriptor size.
public const int ImageDescriptorSize = 10
Field Value
Properties
BackgroundColor
Gets or sets a value for the background color.
public override Color BackgroundColor { get; set; }
Property Value
BitsPerPixel
Gets the image bits per pixel count.
public override int BitsPerPixel { get; }
Property Value
ControlBlock
Gets the graphics control block associated with this block.
public GifGraphicsControlBlock ControlBlock { get; }
Property Value
DisposalMethod
Gets the disposal method.
public AnimationDisposalMethods DisposalMethod { get; }
Property Value
FileFormat
Gets a value of file format
public override FileFormat FileFormat { get; }
Property Value
Flags
Gets or sets the flags.
public byte Flags { get; set; }
Property Value
FrameLeft
Gets the left.
public int FrameLeft { get; }
Property Value
FrameTime
Gets or sets the duration.
public int FrameTime { get; set; }
Property Value
FrameTop
Converts to p.
public int FrameTop { get; }
Property Value
GifFrameBitsPerPixel
Gets or sets the GIF frame bits per pixel.
public byte GifFrameBitsPerPixel { get; set; }
Property Value
HasTransparentColor
Gets a value indicating whether frame block has transparent color.
public override bool HasTransparentColor { get; set; }
Property Value
Height
Gets the image height.
public override int Height { get; }
Property Value
Interlaced
Gets or sets a value indicating whether this Aspose.Imaging.FileFormats.Gif.Blocks.GifFrameBlock is interlaced.
public bool Interlaced { get; set; }
Property Value
IsInterlaced
Gets a value indicating whether this image instance is interlaced.
public bool IsInterlaced { get; }
Property Value
IsPaletteSorted
Gets or sets a value indicating whether color palette is sorted.
public bool IsPaletteSorted { get; set; }
Property Value
Left
Gets or sets the left image location.
[JsonProperty]
public ushort Left { get; set; }
Property Value
Top
Gets or sets the top image location.
[JsonProperty]
public ushort Top { get; set; }
Property Value
TransparentColor
Gets the transparent color of frame block.
public override Color TransparentColor { get; set; }
Property Value
UseAlphaBlending
Gets a value indicating whether [use alpha blending].
public bool UseAlphaBlending { get; }
Property Value
Width
Gets the image width.
public override int Width { get; }
Property Value
Methods
AdjustBrightness(int)
Adjust of a brightness for image.
public override void AdjustBrightness(int brightness)
Parameters
brightness
int
Brightness value.
CreateFlags(IColorPalette, bool, bool)
Creates the flags.
public static byte CreateFlags(IColorPalette colorPalette, bool isPaletteSorted, bool isGifFrameInterlaced)
Parameters
colorPalette
IColorPalette
The color palette.
isPaletteSorted
bool
if set to true
the colors in color palette are sorted.
isGifFrameInterlaced
bool
if set to true
the GIF frame image is interlaced.
Returns
The created flags.
GetColorPalette(IColorPalette, IColorPalette)
Gets the associated color palette.
public static IColorPalette GetColorPalette(IColorPalette framePalette, IColorPalette containerPalette)
Parameters
framePalette
IColorPalette
The frame palette.
containerPalette
IColorPalette
The container palette.
Returns
The color palette.
GetFullFrame()
Gets the full frame.
public RasterImage GetFullFrame()
Returns
he RasterImage with full frame
Exceptions
GetOriginalOptions()
Gets the options based on the original file settings. 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 the Aspose.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 them to 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.
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.
ReplaceColor(int, byte, int)
Replaces one color to another with allowed difference and preserves original alpha value to save smooth edges.
public override void ReplaceColor(int oldColorArgb, byte oldColorDiff, int newColorArgb)
Parameters
oldColorArgb
int
Old color ARGB value to be replaced.
oldColorDiff
byte
Allowed difference in old color to be able to widen replaced color tone.
newColorArgb
int
New color ARGB value to replace old color with.
ReplaceNonTransparentColors(int)
Replaces all non-transparent colors with new color and preserves original alpha value to save smooth edges. Note: if you use it on images without transparency, all colors will be replaced with a single one.
public override void ReplaceNonTransparentColors(int newColorArgb)
Parameters
newColorArgb
int
New color ARGB value to replace non transparent colors with.
Resize(int, int, ImageResizeSettings)
Resizes this Aspose.Imaging.RasterCachedImage instance.
public override void Resize(int newWidth, int newHeight, ImageResizeSettings imageResizeSettings)
Parameters
newWidth
int
New width.
newHeight
int
New height.
imageResizeSettings
ImageResizeSettings
Resize settings.
SaveData(Stream)
Saves the data.
protected override void SaveData(Stream stream)
Parameters
stream
Stream
The stream to save data to.
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.