pub const ICONS: [&[u8]; 6] = [
include_bytes!("../assets/1.png"),
include_bytes!("../assets/2.png"),
include_bytes!("../assets/3.png"),
include_bytes!("../assets/4.png"),
include_bytes!("../assets/5.png"),
include_bytes!("../assets/6.png"),
];
#[inline]
pub fn get_icon(load: u8) -> (&'static [u8], u8) {
match load {
0..=16 => (ICONS[0], 0),
17..=33 => (ICONS[1], 1),
34..=50 => (ICONS[2], 2),
51..=67 => (ICONS[3], 3),
68..=84 => (ICONS[4], 4),
_ => (ICONS[5], 5),
}
}
#[inline]
pub fn load_icon(load: u8) -> (tray_icon::Icon, u8) {
let (bytes, index) = get_icon(load);
let (icon_rgba, icon_width, icon_height) = {
let image = image::load_from_memory(bytes)
.expect("Failed to parse icon bytes")
.into_rgba8();
let (width, height) = image.dimensions();
let rgba = image.into_raw();
(rgba, width, height)
};
(
tray_icon::Icon::from_rgba(icon_rgba, icon_width, icon_height)
.expect("Failed to parse icon"),
index,
)
}
#[inline]
pub fn icon_zero_muda() -> muda::Icon {
let (bytes, _index) = get_icon(0);
let (icon_rgba, icon_width, icon_height) = {
let image = image::load_from_memory(bytes)
.expect("Failed to parse icon bytes")
.into_rgba8();
let (width, height) = image.dimensions();
let rgba = image.into_raw();
(rgba, width, height)
};
muda::Icon::from_rgba(icon_rgba, icon_width, icon_height).expect("Failed to parse icon")
}