use kahlo::{prelude::*, Bitmap}; pub fn load_test_resource(name: &'static str) -> Bitmap { let mut path = std::path::PathBuf::new(); path.push(env!("CARGO_MANIFEST_DIR")); path.push("test_resources"); path.push(name); let file_reader = std::io::BufReader::new(std::fs::File::open(path).expect("couldn't open test resource")); let img = image::load(file_reader, image::ImageFormat::from_path(name).unwrap()) .expect("couldn't parse test resource") .into_rgba8(); let (w, h) = (img.width(), img.height()); Bitmap::new_from_vec(img.into_vec(), w as usize, h as usize, w as usize * 4) } pub fn save_test_result_rgba32( name: &'static str, bitmap: &impl BitmapAccess, ) { let mut path = std::path::PathBuf::new(); path.push(env!("CARGO_TARGET_TMPDIR")); path.push(name); assert_eq!(bitmap.row_stride(), bitmap.width() * 4); image::save_buffer( path, bitmap.data().data(), bitmap.width() as u32, bitmap.height() as u32, image::ExtendedColorType::Rgba8, ) .expect("couldn't save test result"); }