use std::path::Path; pub struct Image { pub bytes: Vec, pub size: Size, pub pitch: usize, } impl Image { pub fn load(path: impl AsRef) -> Result { let image = image::open(path.as_ref())?.flipv().to_rgba8(); let height = image.height(); let width = image.width(); let pitch = image .sample_layout() .height_stride .max(image.sample_layout().width_stride); Ok(Image { bytes: image.into_raw(), pitch, size: Size { height, width }, }) } } use crate::Size; pub use image::ImageError;