mindustry logic execution, map- and schematic- parsing and rendering
eradicate `image`
bendn 2023-10-31
parent 84db6ba · commit 49e801f
-rw-r--r--mindus/Cargo.toml4
-rw-r--r--mindus/build.rs21
2 files changed, 8 insertions, 17 deletions
diff --git a/mindus/Cargo.toml b/mindus/Cargo.toml
index 5477f4a..22fd88c 100644
--- a/mindus/Cargo.toml
+++ b/mindus/Cargo.toml
@@ -25,14 +25,14 @@ bobbin-bits = "0.1"
blurslice = { version = "0.1" }
enum_dispatch = "0.3"
phf = { version = "0.11", features = ["macros"] }
-fimg = { version = "0.4.21", features = ["scale"], default-features = false }
+fimg = { version = "0.4.22", features = ["scale"], default-features = false }
[features]
bin = ["fimg/save"]
default = ["bin"]
[build-dependencies]
-image = { version = "0.24", features = ["png"], default-features = false }
+fimg = { version = "0.4.22", features = ["scale", "save"] }
walkdir = "2"
[[bin]]
diff --git a/mindus/build.rs b/mindus/build.rs
index 4c317cd..cfb9416 100644
--- a/mindus/build.rs
+++ b/mindus/build.rs
@@ -1,8 +1,7 @@
#![feature(let_chains)]
-use image::codecs::png::PngDecoder;
-use image::DynamicImage;
+use fimg::DynImage;
use std::fs::File;
-use std::io::{BufReader, Write as _};
+use std::io::Write as _;
use std::iter::Iterator;
use std::path::Path;
use walkdir::WalkDir;
@@ -63,10 +62,7 @@ fn main() {
&& let Some(e) = path.extension()
&& e == "png"
{
- let p = DynamicImage::from_decoder(
- PngDecoder::new(BufReader::new(File::open(path).unwrap())).unwrap(),
- )
- .unwrap();
+ let mut p = DynImage::open(path);
if path
.file_name()
.unwrap()
@@ -136,20 +132,15 @@ fn main() {
let new = if $scale == 1 {
p.clone()
} else {
- DynamicImage::ImageRgba8(image::imageops::resize(
- &p,
- mx / $scale,
- my / $scale,
- image::imageops::Nearest,
- ))
+ p.scale::<fimg::scale::Nearest>(mx / $scale, my / $scale)
};
let x = new.width();
let y = new.height();
if rgb {
- buf.write_all(&new.into_rgb8().into_raw()).unwrap();
+ buf.write_all(&new.to_rgb().bytes()).unwrap();
wr!($ext => r#"pub(crate) static {path}: Image<&[u8], 3> = unsafe {{ Image::new(std::num::NonZeroU32::new({x}).unwrap(), std::num::NonZeroU32::new({y}).unwrap(), include_bytes!("{out_path}")) }};"#);
} else {
- buf.write_all(&new.into_rgba8().into_raw()).unwrap();
+ buf.write_all(&new.to_rgba().bytes()).unwrap();
wr!($ext => r#"pub(crate) static {path}: Image<&[u8], 4> = unsafe {{ Image::new(std::num::NonZeroU32::new({x}).unwrap(), std::num::NonZeroU32::new({y}).unwrap(), include_bytes!("{out_path}")) }};"#);
}
};