use crate::error::Error;
use std::path::Path;
use std::process::exit;
use winit::window::Icon;
pub fn load_icon(path: &Path) -> Icon {
let (icon_rgba, icon_width, icon_height) = {
let image = match image::open(path) {
Ok(img) => img.into_rgba8(),
Err(err) => {
let message = format!("{}\nExit the application", err.to_string());
Error::new(message.as_str()).error();
exit(1);
}
};
let (width, height) = image.dimensions();
let rgba = image.into_raw();
(rgba, width, height)
};
Icon::from_rgba(icon_rgba, icon_width, icon_height).expect("Failed to open icon")
}