ui: include desktop icon into binary

This commit is contained in:
ardocrat 2024-06-12 10:35:05 +03:00
parent 7ce77e85af
commit 7e53fc2dd6

View file

@ -12,6 +12,8 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
use eframe::icon_data::from_png_bytes;
pub fn main() { pub fn main() {
#[allow(dead_code)] #[allow(dead_code)]
#[cfg(not(target_os = "android"))] #[cfg(not(target_os = "android"))]
@ -32,7 +34,7 @@ fn real_main() {
use grim::AppConfig; use grim::AppConfig;
use std::sync::Arc; use std::sync::Arc;
use egui::{IconData, pos2}; use egui::pos2;
let platform = Desktop::default(); let platform = Desktop::default();
@ -54,14 +56,8 @@ fn real_main() {
.with_inner_size([width, height]); .with_inner_size([width, height]);
// Setup an icon. // Setup an icon.
if let Ok(image) = image::open("img/icon.png") { if let Ok(icon) = from_png_bytes(include_bytes!("../img/icon.png")) {
let icon = image.to_rgba8(); viewport = viewport.with_icon(Arc::new(icon));
let (icon_width, icon_height) = icon.dimensions();
viewport = viewport.with_icon(Arc::new(IconData {
rgba: icon.into_raw(),
width: icon_width,
height: icon_height,
}));
} }
// Setup window position. // Setup window position.