Table of Contents

Class AnimEncoder

Namespace
Imazen.WebP
Assembly
Imazen.WebP.dll

Encodes multiple frames into an animated WebP image. Uses libwebpmux's WebPAnimEncoder internally.

public class AnimEncoder : IDisposable
Inheritance
AnimEncoder
Implements
Inherited Members

Constructors

AnimEncoder(int, int)

Creates an animation encoder with default options.

public AnimEncoder(int width, int height)

Parameters

width int

Canvas width in pixels.

height int

Canvas height in pixels.

AnimEncoder(int, int, int, uint, bool, bool)

Creates an animation encoder with custom options.

public AnimEncoder(int width, int height, int loopCount = 0, uint backgroundColor = 0, bool allowMixed = false, bool minimizeSize = false)

Parameters

width int

Canvas width in pixels.

height int

Canvas height in pixels.

loopCount int

Number of loop iterations (0 = infinite).

backgroundColor uint

Background color as BGRA packed uint32.

allowMixed bool

Allow mixing lossy and lossless frames.

minimizeSize bool

Minimize output size (slower).

Methods

AddFrame(byte[], int, WebPPixelFormat, int, WebPEncoderConfig)

Adds a frame using an advanced encoder config.

public void AddFrame(byte[] pixels, int stride, WebPPixelFormat format, int timestampMs, WebPEncoderConfig config)

Parameters

pixels byte[]
stride int
format WebPPixelFormat
timestampMs int
config WebPEncoderConfig

AddFrame(byte[], int, WebPPixelFormat, int, float)

Adds a frame of raw pixel data at the given timestamp.

public void AddFrame(byte[] pixels, int stride, WebPPixelFormat format, int timestampMs, float quality = -1)

Parameters

pixels byte[]

Raw pixel data.

stride int

Byte stride per row.

format WebPPixelFormat

Pixel format of the input data.

timestampMs int

Timestamp in milliseconds for this frame.

quality float

0-100 for lossy, -1 for lossless.

AddFrame(byte[], int, float)

Adds a frame of raw BGRA pixel data at the given timestamp.

public void AddFrame(byte[] bgraPixels, int timestampMs, float quality = -1)

Parameters

bgraPixels byte[]

BGRA pixel data (width * height * 4 bytes).

timestampMs int

Timestamp in milliseconds for this frame.

quality float

0-100 for lossy, -1 for lossless.

Assemble()

Assembles all added frames into the final animated WebP data.

public byte[] Assemble()

Returns

byte[]

Encoded animated WebP bytes.

Assemble(Stream)

Assembles and writes to a stream.

public void Assemble(Stream outputStream)

Parameters

outputStream Stream

Dispose()

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

public void Dispose()