Skip to content

Commit

Permalink
Update image to 0.23 (rust-windowing#1485)
Browse files Browse the repository at this point in the history
Also makes use of a few ergonomics improvements that were introduced or
optimized in the more recent version.
  • Loading branch information
HeroicKatora authored Mar 3, 2020
1 parent 2b14ec2 commit ece2e70
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
10 changes: 4 additions & 6 deletions examples/window_icon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down

0 comments on commit ece2e70

Please sign in to comment.