From dd38fab2f36f8aaa3c0c3ef84e8a67c1d71f90cc Mon Sep 17 00:00:00 2001 From: Felix Rabe Date: Thu, 27 Jun 2019 17:59:13 +0200 Subject: [PATCH] examples/window_icon.rs: De-duplicate code (#988) --- examples/window_icon.rs | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/examples/window_icon.rs b/examples/window_icon.rs index 4a8ad31f..8fdcdd40 100644 --- a/examples/window_icon.rs +++ b/examples/window_icon.rs @@ -13,17 +13,7 @@ fn main() { // you'll be bitten by the low-quality downscaling built into the WM. let path = concat!(env!("CARGO_MANIFEST_DIR"), "/examples/icon.png"); - let (icon_rgba, icon_width, icon_height) = { - 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 icon = load_icon(Path::new(path)); let event_loop = EventLoop::new();