Function turbojpeg::decompress_to_yuv

source ·
pub fn decompress_to_yuv(jpeg_data: &[u8]) -> Result<YuvImage<Vec<u8>>>
Expand description

Decompress a JPEG image to YUV.

Returns a newly allocated YUV image with row alignment of 4. If you have specific requirements regarding memory layout or allocations, please see Decompressor.

§Example

// read JPEG data from file
let jpeg_data = std::fs::read("examples/parrots.jpg")?;

// decompress the JPEG into YUV image
let image = turbojpeg::decompress_to_yuv(&jpeg_data)?;
assert_eq!((image.width, image.height), (384, 256));
assert_eq!(image.pixels.len(), 294912);