WebPFrameBlock

WebPFrameBlock(RasterImage)

初始化WebPFrameBlock

的新实例

班级。

public WebPFrameBlock(RasterImage rasterImage)
范围 类型 描述
rasterImage RasterImage 光栅图像。

也可以看看


WebPFrameBlock(int, int)

初始化WebPFrameBlock类的新实例。

public WebPFrameBlock(int width, int height)
范围 类型 描述
width Int32 宽度。
height Int32 高度。

例子

此示例说明如何使用指定选项创建多帧动画 WebP 图像。

[C#]

string dir = "c:\\temp\\";

Aspose.Imaging.ImageOptions.WebPOptions createOptions = new Aspose.Imaging.ImageOptions.WebPOptions();
createOptions.Lossless = true;
createOptions.Quality = 100f;
createOptions.AnimBackgroundColor = (uint)Aspose.Imaging.Color.Gray.ToArgb();

// 默认帧加上 36 + 36 个附加帧。
createOptions.AnimLoopCount = 36 + 36 + 1;

    // 创建一个 100x100 像素的 WebP 图像。
using (Aspose.Imaging.FileFormats.Webp.WebPImage webPImage = new Aspose.Imaging.FileFormats.Webp.WebPImage(100, 100, createOptions))
{
        // 第一个圆圈是red
    Aspose.Imaging.Brushes.SolidBrush brush1 = new Aspose.Imaging.Brushes.SolidBrush(Aspose.Imaging.Color.Red);

        //第二个圆圈是black
    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.Webp.WebPFrameBlock block = new Aspose.Imaging.FileFormats.Webp.WebPFrameBlock(100, 100);
        Aspose.Imaging.Graphics graphics = new Aspose.Imaging.Graphics(block);
        graphics.FillPie(brush1, block.Bounds, 0, angle);

        webPImage.AddBlock(block);
    }

        // 逐渐增加黑弧的角度,抹去红弧。
    for (int angle = 10; angle <= 360; angle += 10)
    {
        Aspose.Imaging.FileFormats.Webp.WebPFrameBlock block = new Aspose.Imaging.FileFormats.Webp.WebPFrameBlock(100, 100);

        Aspose.Imaging.Graphics graphics = new Aspose.Imaging.Graphics(block);
        graphics.FillPie(brush2, block.Bounds, 0, angle);
        graphics.FillPie(brush1, block.Bounds, angle, 360 - angle);

        webPImage.AddBlock(block);
    }

        // 保存到 WebP 文件
    webPImage.Save(dir + "output.webp");
}

也可以看看