Function rgb2yuv420::convert_rgb_to_yuv420 [] [src]

pub fn convert_rgb_to_yuv420(
    img: &[u8],
    width: u32,
    height: u32,
    bytes_per_pixel: usize
) -> Vec<u8>

Converts an RGB image to YUV420

img should contain the pixel data in the following format [r, g, b, ... , r, g, b, ... , r, g, b, ...]

bytes_per_pixel should contain the number of bytes used by one pixel eg.: RGB is 3 bytes and RGBA is 4 bytes

Examples

let rgb = vec![0u8; 12];
let yuv = rgb2yuv420::convert_rgb_to_yuv420(&rgb, 2, 2, 3);
assert_eq!(yuv.len(), rgb.len() / 2);