Edit

SKWebpEncoderFrame Struct

Definition

Represents a single frame in an animated WebP sequence.

public struct SKWebpEncoderFrame
Inheritance
SKWebpEncoderFrame

Examples

Creating a two-frame animated WebP:

using var frame1Bitmap = new SKBitmap(100, 100);
using var frame2Bitmap = new SKBitmap(100, 100);
// ... draw into bitmaps ...

var frames = new[]
{
    new SKWebpEncoderFrame(frame1Bitmap, TimeSpan.FromMilliseconds(100)),
    new SKWebpEncoderFrame(frame2Bitmap, TimeSpan.FromMilliseconds(100)),
};
using var data = SKWebpEncoder.EncodeAnimated(frames, SKWebpEncoderOptions.Default);

Remarks

`SKWebpEncoderFrame` combines pixel data (as an <xref:SkiaSharp.SKPixmap>) and a display duration for use with <xref:SkiaSharp.SKWebpEncoder.EncodeAnimated*>.

When constructed from an <xref:SkiaSharp.SKBitmap> or <xref:SkiaSharp.SKImage>, the constructor calls `PeekPixels()` to obtain a non-owning view of the pixel data. If pixel data is not available, an exception is thrown.

Constructors

Name Description
SKWebpEncoderFrame(SKBitmap, TimeSpan)

Initializes a new instance of the SKWebpEncoderFrame struct from a bitmap and a display duration.

SKWebpEncoderFrame(SKImage, TimeSpan)

Initializes a new instance of the SKWebpEncoderFrame struct from an image and a display duration.

SKWebpEncoderFrame(SKPixmap, TimeSpan)

Initializes a new instance of the SKWebpEncoderFrame struct from a pixmap and a display duration.

Properties

Name Description
Duration

Gets or sets the display duration of this frame.

Pixmap

Gets or sets the pixel data for this frame.

Applies to