mirror of
https://github.com/italicsjenga/winit-sonoma-fix.git
synced 2025-01-26 03:36:32 +11:00
examples/window_icon.rs: De-duplicate code (#988)
This commit is contained in:
parent
ac08601b40
commit
dd38fab2f3
1 changed files with 1 additions and 11 deletions
|
@ -13,17 +13,7 @@ fn main() {
|
||||||
// you'll be bitten by the low-quality downscaling built into the WM.
|
// you'll be bitten by the low-quality downscaling built into the WM.
|
||||||
let path = concat!(env!("CARGO_MANIFEST_DIR"), "/examples/icon.png");
|
let path = concat!(env!("CARGO_MANIFEST_DIR"), "/examples/icon.png");
|
||||||
|
|
||||||
let (icon_rgba, icon_width, icon_height) = {
|
let icon = load_icon(Path::new(path));
|
||||||
let image = image::open(path).expect("Failed to open icon path");
|
|
||||||
use image::{GenericImageView, Pixel};
|
|
||||||
let (width, height) = image.dimensions();
|
|
||||||
let mut rgba = Vec::with_capacity((width * height) as usize * 4);
|
|
||||||
for (_, _, pixel) in image.pixels() {
|
|
||||||
rgba.extend_from_slice(&pixel.to_rgba().data);
|
|
||||||
}
|
|
||||||
(rgba, width, height)
|
|
||||||
};
|
|
||||||
let icon = Icon::from_rgba(icon_rgba, icon_width, icon_height).expect("Failed to open icon");
|
|
||||||
|
|
||||||
let event_loop = EventLoop::new();
|
let event_loop = EventLoop::new();
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue