fn rgba_to_rgb(data: &[u8]) -> Vec<u8> {
        let mut temp_counter = 0;
        let mut temp = [0u8; 3];
        // Doing `/4*3` will just make things to complicated and images will be small anyway.
        let mut output = Vec::with_capacity(data.len());
        for byte in data {
            match temp_counter {
                0..=2 => {
                    // Store value r, g or b.
                    temp[temp_counter] = *byte;
                    // Increase counter
                    temp_counter += 1;
                }
                _ => {
                    // Skip alpha
                    // and
                    // Color of 1 pixel is consumes (r, g, b, a)
                    output.extend_from_slice(&temp);
                    temp_counter = 0;
                }
            }
        }
        output
    }
// NOTE: This function only works for a bit depth of 8.
This function only works for a bit depth of 8.
This function only works for a bit depth of 8 .
fn rgba_to_rgb(data: &[u8]) -> Vec<u8> {
        let mut temp_counter = 0;
        let mut temp = [0u8; 3];
        // Doing `/4*3` will just make things to complicated and images will be small anyway.
        let mut output = Vec::with_capacity(data.len());
        for byte in data {
            match temp_counter {
                0..=2 => {
                    // Store value r, g or b.
                    temp[temp_counter] = *byte;
                    // Increase counter
                    temp_counter += 1;
                }
                _ => {
                    // Skip alpha
                    // and
                    // Color of 1 pixel is consumes (r, g, b, a)
                    output.extend_from_slice(&temp);
                    temp_counter = 0;
                }
            }
        }
        output
    }
fn rgba_to_rgb ( data : & [ u8 ] ) -> Vec < u8 > { let mut temp_counter = 0 ; let mut temp = [ 0u8 ; 3 ] ; // Doing `/4*3` will just make things to complicated and images will be small anyway. let mut output = Vec :: with_capacity ( data . len ( ) ) ; for byte in data { match temp_counter { 0 ..= 2 => { // Store value r, g or b. temp [ temp_counter ] = * byte ; // Increase counter temp_counter += 1 ; } _ => { // Skip alpha // and // Color of 1 pixel is consumes (r, g, b, a) output . extend_from_slice ( & temp ) ; temp_counter = 0 ; } } } output }
NOTE: This function only works for a bit depth of 8.
NOTE : This function only works for a bit depth of 8 .
data
&[u8]