Function turbojpeg::yuv_pixels_len
source · pub fn yuv_pixels_len(
width: usize,
align: usize,
height: usize,
subsamp: Subsamp
) -> Result<usize>
Expand description
Determine size in bytes of a YUV image.
Calculates the size for YuvImage::pixels
based on the image width, height, chrominance
subsampling and row alignment.
Returns an error on integer overflow. You can just .unwrap()
the result if you don’t care
about this edge case.
§Example
// read JPEG data from file
let jpeg_data = std::fs::read("examples/parrots.jpg")?;
// read the JPEG header
let header = turbojpeg::read_header(&jpeg_data)?;
// get YUV pixels length
let align = 4;
let yuv_pixels_len = turbojpeg::yuv_pixels_len(header.width, align, header.height, header.subsamp);
assert_eq!(yuv_pixels_len.unwrap(), 294912);