Custom for icon
This commit is contained in:
1 parent
aad055cd84
commit
78ac592c0a
2 files changed
+17
No files matched your search
@@ -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]
|
||||
|
||||
@@ -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()
|
||||
|
||||
Reference in new issue
Block a user