pub fn from_rgba(rgba: Vec<u8>, width: u32, height: u32) -> Result<Self, BadIcon> {
        if rgba.len() % PIXEL_SIZE != 0 {
            return Err(BadIcon::ByteCountNotDivisibleBy4 {
                byte_count: rgba.len(),
            });
        }
        let pixel_count = rgba.len() / PIXEL_SIZE;
        if pixel_count != (width * height) as usize {
            Err(BadIcon::DimensionsVsPixelCount {
                width,
                height,
                width_x_height: (width * height) as usize,
                pixel_count,
            })
        } else {
            Ok(Icon {
                rgba,
                width,
                height,
            })
        }
    }
/// Creates an `Icon` from 32bpp RGBA data.
///
/// The length of `rgba` must be divisible by 4, and `width * height` must equal
/// `rgba.len() / 4`. Otherwise, this will return a `BadIcon` error.
Creates an `Icon` from 32bpp RGBA data.
Creates an ` Icon ` from 32bpp RGBA data .
pub fn from_rgba(rgba: Vec<u8>, width: u32, height: u32) -> Result<Self, BadIcon> {
        if rgba.len() % PIXEL_SIZE != 0 {
            return Err(BadIcon::ByteCountNotDivisibleBy4 {
                byte_count: rgba.len(),
            });
        }
        let pixel_count = rgba.len() / PIXEL_SIZE;
        if pixel_count != (width * height) as usize {
            Err(BadIcon::DimensionsVsPixelCount {
                width,
                height,
                width_x_height: (width * height) as usize,
                pixel_count,
            })
        } else {
            Ok(Icon {
                rgba,
                width,
                height,
            })
        }
    }
pub fn from_rgba ( rgba : Vec < u8 > , width : u32 , height : u32 ) -> Result < Self , BadIcon > { if rgba . len ( ) % PIXEL_SIZE != 0 { return Err ( BadIcon :: ByteCountNotDivisibleBy4 { byte_count : rgba . len ( ) , } ) ; } let pixel_count = rgba . len ( ) / PIXEL_SIZE ; if pixel_count != ( width * height ) as usize { Err ( BadIcon :: DimensionsVsPixelCount { width , height , width_x_height : ( width * height ) as usize , pixel_count , } ) } else { Ok ( Icon { rgba , width , height , } ) } }
Creates an `Icon` from 32bpp RGBA data.
Creates an ` Icon ` from 32bpp RGBA data .
rgba
Vec<u8>
width
u32
height
u32
rgba
Vec<u8>
width
u32
height
u32