pub fn WebPDecodeYUVInto(
data: &[u8],
luma: &mut [u8],
luma_stride: u32,
u: &mut [u8],
u_stride: u32,
v: &mut [u8],
v_stride: u32,
) -> Result<(), WebPSimpleError>
Expand description
A variant of WebPDecodeYUVInto
that operates directly into
pre-allocated buffers.
§Errors
Returns Err
if data
doesn’t contain a valid WebP image, or
any of the buffers is too small.
§Examples
use libwebp::{WebPGetInfo, WebPDecodeYUVInto};
let data: &[u8];
let (width, height) = WebPGetInfo(data).expect("Invalid WebP header");
let luma_stride = width;
let u_stride = (width + 1) / 2;
let v_stride = (width + 1) / 2;
let mut luma = vec![0; luma_stride as usize * height as usize];
let mut u = vec![0; u_stride as usize * ((height + 1) / 2) as usize];
let mut v = vec![0; v_stride as usize * ((height + 1) / 2) as usize];
WebPDecodeYUVInto(
data,
&mut luma,
luma_stride,
&mut u,
u_stride,
&mut v,
v_stride,
).expect("Invalid WebP header");
eprintln!(
"top-left pixel: yuv({}, {}, {})",
luma[0],
u[0],
v[0],
)