From 7e53fc2dd68b0850436804c1adb2a21982d3f87f Mon Sep 17 00:00:00 2001 From: ardocrat Date: Wed, 12 Jun 2024 10:35:05 +0300 Subject: [PATCH] ui: include desktop icon into binary --- src/main.rs | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/src/main.rs b/src/main.rs index 6e4c7b6..29b267f 100644 --- a/src/main.rs +++ b/src/main.rs @@ -12,6 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. +use eframe::icon_data::from_png_bytes; + pub fn main() { #[allow(dead_code)] #[cfg(not(target_os = "android"))] @@ -32,7 +34,7 @@ fn real_main() { use grim::AppConfig; use std::sync::Arc; - use egui::{IconData, pos2}; + use egui::pos2; let platform = Desktop::default(); @@ -54,14 +56,8 @@ fn real_main() { .with_inner_size([width, height]); // Setup an icon. - if let Ok(image) = image::open("img/icon.png") { - let icon = image.to_rgba8(); - let (icon_width, icon_height) = icon.dimensions(); - viewport = viewport.with_icon(Arc::new(IconData { - rgba: icon.into_raw(), - width: icon_width, - height: icon_height, - })); + if let Ok(icon) = from_png_bytes(include_bytes!("../img/icon.png")) { + viewport = viewport.with_icon(Arc::new(icon)); } // Setup window position.