[−][src]Crate libwebp
libwebp
This is a binding to the libwebp library.
Usage
Preparation
# Cargo.toml
[dependencies]
libwebp = { version = "0.1.2", features = ["0_6"] }
Simple decoding
You can use WebPDecodeRGBA
or WebPDecodeRGBAInto
families for
simple decoding.
use libwebp::WebPDecodeRGBA; let data: &[u8]; let (width, height, buf) = WebPDecodeRGBA(data).unwrap(); assert_eq!(buf.len(), width as usize * height as usize * 4); eprintln!("width = {}, height = {}", width, height); eprintln!( "top-left pixel: rgba({}, {}, {}, {})", buf[0], buf[1], buf[2], buf[3] as f64 / 255.0, )
Simple encoding
You can use WebPEncodeRGBA
or WebPEncodeLosslessRGBA
families for
simple encoding.
use libwebp::{WebPEncodeRGBA, WebPEncodeLosslessRGBA}; let buf: &[u8] = &[ 255, 255, 255, 255, // white 255, 0, 0, 255, // red 0, 255, 0, 255, // green 0, 0, 255, 255, // blue ]; let data = WebPEncodeRGBA(buf, 2, 2, 8, 75.0).unwrap(); let lossless_data = WebPEncodeLosslessRGBA(buf, 2, 2, 8).unwrap(); assert_eq!(&data[..4], b"RIFF"); assert_eq!(&data[8..12], b"WEBP"); assert_eq!(&lossless_data[..4], b"RIFF"); assert_eq!(&lossless_data[8..12], b"WEBP");
Modules
boxed | Safe RAII wrappers for |
error | Error type definitions. |
Structs
WebPIDecGetRGBResult | |
WebPIDecGetYUVAResult | |
WebPIDecoder |
Enums
VP8StatusCode | |
WEBP_CSP_MODE |
Functions
WebPDecodeARGB | Same as |
WebPDecodeARGBInto | Same as |
WebPDecodeBGR | Same as |
WebPDecodeBGRA | Same as |
WebPDecodeBGRAInto | Same as |
WebPDecodeBGRInto | Same as |
WebPDecodeRGB | Same as |
WebPDecodeRGBA | Decodes WebP images pointed to by |
WebPDecodeRGBAInto | Decodes WebP images pointed to by |
WebPDecodeRGBInto | Same as |
WebPDecodeYUV | Decodes WebP images pointed to by |
WebPDecodeYUVInto | A variant of |
WebPEncodeBGR | Same as |
WebPEncodeBGRA | Same as |
WebPEncodeLosslessBGR | Same as |
WebPEncodeLosslessBGRA | Same as |
WebPEncodeLosslessRGB | Same as |
WebPEncodeLosslessRGBA | Encodes images pointed to by |
WebPEncodeRGB | Same as |
WebPEncodeRGBA | Encodes images pointed to by |
WebPGetDecoderVersion | Return the decoder's version number, packed in hexadecimal using 8bits for each of major/minor/revision. |
WebPGetEncoderVersion | Return the encoder's version number, packed in hexadecimal using 8bits for each of major/minor/revision. |
WebPGetInfo | Retrieve basic header information: width, height. |
WebPIAppend | |
WebPIDecGetRGB | |
WebPIDecGetYUVA | |
WebPINewDecoder | |
WebPINewRGB | |
WebPINewYUVA | |
WebPIsAlphaMode | |
WebPIsPremultipliedMode | |
WebPIsRGBMode |