/// Converts RGBA image data into RGB.
Converts RGBA image data into RGB.
Converts RGBA image data into RGB .
fn rgba_to_rgb(rgba: &[u8]) -> Box<[u8]> {
    assert_eq!(rgba.len() % 4, 0);
    let num_pixels = rgba.len() / 4;
    let mut rgb = Vec::with_capacity(num_pixels * 3);
    for i in 0..num_pixels {
        rgb.extend_from_slice(&rgba[(4 * i)..(4 * i + 3)]);
    }
    rgb.into_boxed_slice()
}
fn rgba_to_rgb ( rgba : & [ u8 ] ) -> Box < [ u8 ] > { assert_eq ! ( rgba len ( ) 4 0 ) ; let num_pixels = rgba . len ( ) / 4 ; let mut rgb = Vec :: with_capacity ( num_pixels * 3 ) ; for i in 0 .. num_pixels { rgb . extend_from_slice ( & rgba [ ( 4 * i ) .. ( 4 * i + 3 ) ] ) ; } rgb . into_boxed_slice ( ) }
Converts RGBA image data into RGB.
Converts RGBA image data into RGB .
rgba
&[u8]