AddPage

GifImage.AddPage method

Adds page to the image.

public void AddPage(RasterImage page)
ParameterTypeDescription
pageRasterImageThe page to add.

Exceptions

exceptioncondition
ArgumentNullExceptionpage is null.

Examples

Create multipage GIF image using single page raster images.

[C#]

static void Main(string[] args)
{
    // Load frames
    var frames = LoadFrames("Animation frames").ToArray();

    // Create GIF image using the first frame
    using (var image = new GifImage(new GifFrameBlock(frames[0])))
    {
        // Add frames to the GIF image using the AddPage method
        for (var index = 1; index < frames.Length; index++)
        {
            image.AddPage(frames[index]);
        }

        // Save GIF image
        image.Save("Multipage.gif");
    }
}

private static IEnumerable<RasterImage> LoadFrames(string directory)
{
    foreach (var filePath in Directory.GetFiles(directory))
    {
        yield return (RasterImage)Image.Load(filePath);
    }
}

See Also