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

+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()