From ece2e70a53fd469341e89e2bbc293910882d6d6c Mon Sep 17 00:00:00 2001 From: HeroicKatora Date: Wed, 4 Mar 2020 00:13:53 +0100 Subject: [PATCH] Update image to 0.23 (#1485) Also makes use of a few ergonomics improvements that were introduced or optimized in the more recent version. --- Cargo.toml | 2 +- examples/window_icon.rs | 10 ++++------ 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index f0ac5fdd..3ea410c9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -28,7 +28,7 @@ raw-window-handle = "0.3" bitflags = "1" [dev-dependencies] -image = "0.21" +image = "0.23" simple_logger = "1" [target.'cfg(target_os = "android")'.dependencies.android_glue] diff --git a/examples/window_icon.rs b/examples/window_icon.rs index b7c84679..734debf4 100644 --- a/examples/window_icon.rs +++ b/examples/window_icon.rs @@ -45,13 +45,11 @@ fn main() { fn load_icon(path: &Path) -> Icon { let (icon_rgba, icon_width, icon_height) = { - let image = image::open(path).expect("Failed to open icon path"); - use image::{GenericImageView, Pixel}; + let image = image::open(path) + .expect("Failed to open icon path") + .into_rgba(); 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); - } + let rgba = image.into_raw(); (rgba, width, height) }; Icon::from_rgba(icon_rgba, icon_width, icon_height).expect("Failed to open icon")