GifImage Constructor (GifFrameBlock, IColorPalette)
Initializes a new instance of the GifImage class.

Namespace: Aspose.Imaging.FileFormats.Gif
Assembly: Aspose.Imaging (in Aspose.Imaging.dll) Version: 21.04
public GifImage(
	GifFrameBlock firstFrame,
	IColorPalette globalPalette


Type: Aspose.Imaging.FileFormats.Gif.BlocksGifFrameBlock
The first frame to initialize gif image with.
Type: Aspose.ImagingIColorPalette
The global palette to use. Note if both firstFrame and globalPalette are null then default global palette is used.
ArgumentNullExceptionThe frame cannot be null;firstFrame
ArgumentExceptionThe first frame already belongs to some other image. Check the Container property.;firstFrame
GifImageExceptionThe palette specified should contain entries count equal to power of 2. Minimal palette size is 2, maximal is 256.
This example shows how to create a GIF image with a custom palette and save it to a file.

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");
See Also