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