Class AnimEncoder
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
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
widthintCanvas width in pixels.
heightintCanvas height in pixels.
loopCountintNumber of loop iterations (0 = infinite).
backgroundColoruintBackground color as BGRA packed uint32.
allowMixedboolAllow mixing lossy and lossless frames.
minimizeSizeboolMinimize 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
pixelsbyte[]strideintformatWebPPixelFormattimestampMsintconfigWebPEncoderConfig
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
pixelsbyte[]Raw pixel data.
strideintByte stride per row.
formatWebPPixelFormatPixel format of the input data.
timestampMsintTimestamp in milliseconds for this frame.
qualityfloat0-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
bgraPixelsbyte[]BGRA pixel data (width * height * 4 bytes).
timestampMsintTimestamp in milliseconds for this frame.
qualityfloat0-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
outputStreamStream
Dispose()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
public void Dispose()