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:
HeroicKatora
2020-03-04 00:13:53 +01:00
committed by GitHub
parent 2b14ec23d5
commit ece2e70a53
2 changed files with 5 additions and 7 deletions

View File

@@ -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")