SKWebpEncoder Class
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Provides methods for encoding images and animated sequences to the WebP format.
public static class SKWebpEncoder
- Inheritance
-
SKWebpEncoder
Examples
Encoding a bitmap to a WebP file:
using var bitmap = new SKBitmap(200, 200);
using var canvas = new SKCanvas(bitmap);
canvas.DrawColor(SKColors.CornflowerBlue);
using var pixmap = bitmap.PeekPixels();
using var data = SKWebpEncoder.Encode(pixmap, SKWebpEncoderOptions.Default);
File.WriteAllBytes("output.webp", data.ToArray());
Remarks
`SKWebpEncoder` provides static methods for encoding a single <xref:SkiaSharp.SKPixmap> to WebP data, as well as encoding multi-frame animated WebP sequences from a span of <xref:SkiaSharp.SKWebpEncoderFrame> values.
Encoding options such as quality and compression method are specified via <xref:SkiaSharp.SKWebpEncoderOptions>.
Methods
| Name | Description |
|---|---|
| Encode(SKPixmap, SKWebpEncoderOptions) |
Encodes the specified pixel data to the WebP format and returns the result as SKData. |
| Encode(SKWStream, SKPixmap, SKWebpEncoderOptions) |
Encodes the specified pixel data to WebP format and writes the result to the specified stream. |
| Encode(Stream, SKPixmap, SKWebpEncoderOptions) |
Encodes the specified pixel data to WebP format and writes the result to the specified managed stream. |
| EncodeAnimated(ReadOnlySpan<SKWebpEncoderFrame>, SKWebpEncoderOptions) |
Encodes the specified frames as an animated WebP and returns the result as SKData. |
| EncodeAnimated(SKWStream, ReadOnlySpan<SKWebpEncoderFrame>, SKWebpEncoderOptions) |
Encodes the specified frames as an animated WebP and writes the result to the specified stream. |
| EncodeAnimated(Stream, ReadOnlySpan<SKWebpEncoderFrame>, SKWebpEncoderOptions) |
Encodes the specified frames as an animated WebP and writes the result to the specified managed stream. |