Custom for icon

This commit is contained in:
Aster committed 2022-02-13 00:34:45 +08:00
1 parent aad055cd84
commit 78ac592c0a
2 files changed
+17

No files matched your search

+1
View File
@@ -32,6 +32,7 @@ dioxus-html = { path = "../html", features = ["serialize"], version = "^0.1.6" }
webbrowser = "0.5.5"
mime_guess = "2.0.3"
dioxus-interpreter-js = { path = "../interpreter", version = "^0.0.0" }
image = "0.24.0"
[features]
+16
View File
@@ -1,3 +1,6 @@
use image::io::Reader as ImageReader;
use image::ImageFormat;
use std::io::Cursor;
use wry::application::window::Icon;
use wry::{
application::{
@@ -86,6 +89,19 @@ impl DesktopConfig {
}
}
impl DesktopConfig {
pub(crate) fn with_default_icon(mut self) -> Self {
let png: &[u8] = include_bytes!("default_icon.png");
let mut reader = ImageReader::new(Cursor::new(png));
reader.set_format(ImageFormat::Png);
let icon = reader.decode().expect("image parse failed");
let rgba = Icon::from_rgba(icon.as_bytes().to_owned(), icon.width(), icon.height())
.expect("image parse failed");
self.window.window.window_icon = Some(rgba);
self
}
}
impl Default for DesktopConfig {
fn default() -> Self {
Self::new()