mirror of
https://github.com/rust-windowing/winit.git
synced 2026-08-31 05:40:04 -04:00
Update image to 0.23 (#1485)
Also makes use of a few ergonomics improvements that were introduced or optimized in the more recent version.
This commit is contained in:
@@ -28,7 +28,7 @@ raw-window-handle = "0.3"
|
|||||||
bitflags = "1"
|
bitflags = "1"
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
image = "0.21"
|
image = "0.23"
|
||||||
simple_logger = "1"
|
simple_logger = "1"
|
||||||
|
|
||||||
[target.'cfg(target_os = "android")'.dependencies.android_glue]
|
[target.'cfg(target_os = "android")'.dependencies.android_glue]
|
||||||
|
|||||||
@@ -45,13 +45,11 @@ fn main() {
|
|||||||
|
|
||||||
fn load_icon(path: &Path) -> Icon {
|
fn load_icon(path: &Path) -> Icon {
|
||||||
let (icon_rgba, icon_width, icon_height) = {
|
let (icon_rgba, icon_width, icon_height) = {
|
||||||
let image = image::open(path).expect("Failed to open icon path");
|
let image = image::open(path)
|
||||||
use image::{GenericImageView, Pixel};
|
.expect("Failed to open icon path")
|
||||||
|
.into_rgba();
|
||||||
let (width, height) = image.dimensions();
|
let (width, height) = image.dimensions();
|
||||||
let mut rgba = Vec::with_capacity((width * height) as usize * 4);
|
let rgba = image.into_raw();
|
||||||
for (_, _, pixel) in image.pixels() {
|
|
||||||
rgba.extend_from_slice(&pixel.to_rgba().data);
|
|
||||||
}
|
|
||||||
(rgba, width, height)
|
(rgba, width, height)
|
||||||
};
|
};
|
||||||
Icon::from_rgba(icon_rgba, icon_width, icon_height).expect("Failed to open icon")
|
Icon::from_rgba(icon_rgba, icon_width, icon_height).expect("Failed to open icon")
|
||||||
|
|||||||
Reference in New Issue
Block a user