mindustry logic execution, map- and schematic- parsing and rendering
use zlib-ng
| -rw-r--r-- | Cargo.toml | 9 | ||||
| -rw-r--r-- | src/utils/image.rs | 22 |
2 files changed, 19 insertions, 12 deletions
@@ -1,6 +1,6 @@ [package] name = "mindus" -version = "4.0.5" +version = "4.0.6" edition = "2021" description = "A library for working with mindustry data formats (eg schematics and maps) (fork of plandustry)" authors = [ @@ -11,14 +11,15 @@ repository = "https://github.com/bend-n/mindus.git" license = "GPL-3.0" exclude = [".github/", "items.py"] readme = "README.md" +keywords = ["mindustry", "format", "drawing"] [dependencies] -flate2 = { version = "1.0", features = ["zlib"], default-features = false } +flate2 = { version = "1.0", features = ["zlib-ng"], default-features = false } base64 = "0.21" paste = "1.0" strconv = "0.1" amap = "0.1" -image = { version = "0.24", features = [], default-features = false, optional = true } +png = { version = "0.17", features = ["unstable"], optional = true } color-hex = "0.2" thiserror = "1.0" bobbin-bits = "0.1" @@ -28,7 +29,7 @@ fast_image_resize = "2.7" phf = { version = "0.11", features = ["macros"] } [features] -bin = ["image/png"] +bin = ["png"] default = ["bin"] [build-dependencies] diff --git a/src/utils/image.rs b/src/utils/image.rs index 8254bb7..b968dc6 100644 --- a/src/utils/image.rs +++ b/src/utils/image.rs @@ -478,14 +478,20 @@ impl Image<Vec<u8>, 4> { impl Image<Vec<u8>, 3> { #[cfg(feature = "bin")] pub fn save(&self, f: impl AsRef<std::path::Path>) { - image::save_buffer( - f, - &self.buffer, - self.width(), - self.height(), - image::ColorType::Rgb8, - ) - .unwrap(); + let p = std::fs::File::create(f).unwrap(); + let w = &mut std::io::BufWriter::new(p); + let mut enc = png::Encoder::new(w, self.width(), self.height()); + enc.set_color(png::ColorType::Rgb); + enc.set_depth(png::BitDepth::Eight); + enc.set_source_gamma(png::ScaledFloat::new(1.0 / 2.2)); + enc.set_source_chromaticities(png::SourceChromaticities::new( + (0.31270, 0.32900), + (0.64000, 0.33000), + (0.30000, 0.60000), + (0.15000, 0.06000), + )); + let mut writer = enc.write_header().unwrap(); + writer.write_image_data(&self.buffer).unwrap(); } } |