Function libwebp::WebPDecodeRGBA
source · Expand description
Decodes WebP images pointed to by data
and returns RGBA samples, along
with the dimensions (width and height).
The ordering of samples in memory is R, G, B, A, R, G, B, A… in scan order (endian-independent).
Errors
Returns Err
if data
doesn’t contain a valid WebP image.
Variants
WebPDecodeRGBA
WebPDecodeARGB
WebPDecodeBGRA
WebPDecodeRGB
WebPDecodeBGR
Examples
use libwebp::WebPDecodeRGBA;
let data: &[u8];
let (width, height, buf) = WebPDecodeRGBA(data).expect("Invalid WebP data");
assert_eq!(buf.len(), width as usize * height as usize * 4);
eprintln!(
"top-left pixel: rgba({}, {}, {}, {})",
buf[0],
buf[1],
buf[2],
buf[3] as f64 / 255.0,
)