[−][src]Function libwebp::WebPDecodeRGBAInto
pub fn WebPDecodeRGBAInto(
data: &[u8],
output_buffer: &mut [u8],
output_stride: u32
) -> Result<(), WebPSimpleError>
Decodes WebP images pointed to by data
and writes RGBA samples to
output_buffer
.
The parameter 'output_stride' specifies the distance (in bytes)
between scanlines. Hence, output_buffer.len()
is expected to be at least
output_stride
x picture-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, or
output_buffer
is too small.
Variants
WebPDecodeRGBAInto
WebPDecodeARGBInto
WebPDecodeBGRAInto
WebPDecodeRGBInto
WebPDecodeBGRInto
Examples
use libwebp::{WebPGetInfo, WebPDecodeRGBAInto}; let data: &[u8]; let (width, height) = WebPGetInfo(data).expect("Invalid WebP header"); let stride = width * 4; let mut buf = vec![0; stride as usize * height as usize]; WebPDecodeRGBAInto(data, &mut buf, stride).expect("Invalid WebP data"); eprintln!( "top-left pixel: rgba({}, {}, {}, {})", buf[0], buf[1], buf[2], buf[3] as f64 / 255.0, )