GifFrameBlock

GifFrameBlock constructor (1 of 12)

Initializes a new instance of the GifFrameBlock class.

public GifFrameBlock(ushort width, ushort height)
ParameterTypeDescription
widthUInt16The image width.
heightUInt16The image height.

Examples

This example shows how to create a GIF image and save it to a file.

[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.

[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.

[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");
}

See Also


GifFrameBlock constructor (2 of 12)

Initializes a new instance of the GifFrameBlock class.

public GifFrameBlock(ushort left, ushort top, ushort width, ushort height)
ParameterTypeDescription
leftUInt16The left image position.
topUInt16The top image position.
widthUInt16The image width.
heightUInt16The image height.

See Also


GifFrameBlock constructor (3 of 12)

Initializes a new instance of the GifFrameBlock class.

public GifFrameBlock(ushort left, ushort top, ushort width, ushort height, 
    IColorPalette colorPalette, bool isPaletteSorted, bool isGifFrameInterlaced, byte bitsPerPixel)
ParameterTypeDescription
leftUInt16The left image position.
topUInt16The top image position.
widthUInt16The image Width.
heightUInt16The image Height.
colorPaletteIColorPaletteThe color palette.
isPaletteSortedBooleanif set to true the color palette is sorted.
isGifFrameInterlacedBooleanif set to true the GIF frame is interlaced.
bitsPerPixelByteThe bits per pixel.

See Also


GifFrameBlock constructor (4 of 12)

Initializes a new instance of the GifFrameBlock class.

public GifFrameBlock(RasterImage image)
ParameterTypeDescription
imageRasterImageThe image to initialize frame pixel and palette data with.

See Also


GifFrameBlock constructor (5 of 12)

Initializes a new instance of the GifFrameBlock class.

public GifFrameBlock(RasterImage image, ushort left, ushort top)
ParameterTypeDescription
imageRasterImageThe image to initialize frame pixel and palette data with.
leftUInt16The left image position.
topUInt16The top image position.

See Also


GifFrameBlock constructor (6 of 12)

Initializes a new instance of the GifFrameBlock class.

public GifFrameBlock(RasterImage image, ushort left, ushort top, bool isPaletteSorted, 
    bool isGifFrameInterlaced, byte lzwCodeSize)
ParameterTypeDescription
imageRasterImageThe image to initialize frame pixel and palette data with.
leftUInt16The left image position.
topUInt16The top image position.
isPaletteSortedBooleanif set to true the color palette is sorted.
isGifFrameInterlacedBooleanif set to true the GIF frame is interlaced.
lzwCodeSizeByteThe bits per pixel.

See Also


GifFrameBlock constructor (7 of 12)

Initializes a new instance of the GifFrameBlock class.

public GifFrameBlock(Stream stream)
ParameterTypeDescription
streamStreamThe stream to load an image from and initialize frame pixel and palette data with.

See Also


GifFrameBlock constructor (8 of 12)

Initializes a new instance of the GifFrameBlock class.

public GifFrameBlock(Stream stream, ushort left, ushort top)
ParameterTypeDescription
streamStreamThe stream to load an image from and initialize frame pixel and palette data with.
leftUInt16The left image position.
topUInt16The top image position.

See Also


GifFrameBlock constructor (9 of 12)

Initializes a new instance of the GifFrameBlock class.

public GifFrameBlock(Stream stream, ushort left, ushort top, bool isPaletteSorted, 
    bool isGifFrameInterlaced, byte lzwCodeSize)
ParameterTypeDescription
streamStreamThe stream to load an image from and initialize frame pixel and palette data with.
leftUInt16The left image position.
topUInt16The top image position.
isPaletteSortedBooleanif set to true the color palette is sorted.
isGifFrameInterlacedBooleanif set to true the GIF frame is interlaced.
lzwCodeSizeByteThe bits per pixel.

See Also


GifFrameBlock constructor (10 of 12)

Initializes a new instance of the GifFrameBlock class.

public GifFrameBlock(string path)
ParameterTypeDescription
pathStringThe path to load an image from and initialize frame pixel and palette data with.

See Also


GifFrameBlock constructor (11 of 12)

Initializes a new instance of the GifFrameBlock class.

public GifFrameBlock(string path, ushort left, ushort top)
ParameterTypeDescription
pathStringThe path to load an image from and initialize frame pixel and palette data with.
leftUInt16The left image position.
topUInt16The top image position.

See Also


GifFrameBlock constructor (12 of 12)

Initializes a new instance of the GifFrameBlock class.

public GifFrameBlock(string path, ushort left, ushort top, bool isPaletteSorted, 
    bool isGifFrameInterlaced, byte lzwCodeSize)
ParameterTypeDescription
pathStringThe path to load an image from and initialize frame pixel and palette data with.
leftUInt16The left image position.
topUInt16The top image position.
isPaletteSortedBooleanif set to true the color palette is sorted.
isGifFrameInterlacedBooleanif set to true the GIF frame is interlaced.
lzwCodeSizeByteThe bits per pixel.

See Also