mindustry logic execution, map- and schematic- parsing and rendering
| -rw-r--r-- | mindus/Cargo.toml | 5 | ||||
| -rw-r--r-- | mindus/src/block/logic.rs | 2 | ||||
| -rw-r--r-- | mindus/src/utils/image/holder.rs | 4 | ||||
| -rw-r--r-- | mindus/src/utils/image/mod.rs | 20 |
4 files changed, 3 insertions, 28 deletions
diff --git a/mindus/Cargo.toml b/mindus/Cargo.toml index 46c77f8..b348bc0 100644 --- a/mindus/Cargo.toml +++ b/mindus/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "mindus" -version = "5.0.3" +version = "5.0.4" edition = "2021" description = "A library for working with mindustry data formats (eg schematics and maps) (fork of plandustry)" authors = [ @@ -24,9 +24,8 @@ thiserror = "1.0" bobbin-bits = "0.1" blurslice = { version = "0.1" } enum_dispatch = "0.3" -fast_image_resize = "2.7" phf = { version = "0.11", features = ["macros"] } -fimg = { version = "0.4.0", default-features = false } +fimg = { version = "0.4.1", default-features = false } [features] bin = ["fimg/save"] diff --git a/mindus/src/block/logic.rs b/mindus/src/block/logic.rs index 94f26f2..4db95f7 100644 --- a/mindus/src/block/logic.rs +++ b/mindus/src/block/logic.rs @@ -138,7 +138,7 @@ impl BlockLogic for CanvasBlock { (*r, *g, *b) = PALETTE[y as usize]; *a = 255; } - let img = img.as_mut().scale((s * self.size as u32) - offset * 2); + let img = unsafe { fimg::scale::Nearest::scale(img.as_ref(), (s * self.size as u32) - offset * 2, (s * self.size as u32) - offset * 2) }; let mut borders = load!("canvas", s); unsafe { borders diff --git a/mindus/src/utils/image/holder.rs b/mindus/src/utils/image/holder.rs index facd9ef..f44f177 100644 --- a/mindus/src/utils/image/holder.rs +++ b/mindus/src/utils/image/holder.rs @@ -72,10 +72,6 @@ impl ImageUtils for ImageHolder<4> { self.borrow_mut().shadow(); self } - - fn scale(mut self, to: u32) -> Image<Vec<u8>, 4> { - self.borrow_mut().scale(to) - } } impl<const CHANNELS: usize> From<Image<&'static [u8], CHANNELS>> for ImageHolder<CHANNELS> { diff --git a/mindus/src/utils/image/mod.rs b/mindus/src/utils/image/mod.rs index 5bcbb3f..a9aa76e 100644 --- a/mindus/src/utils/image/mod.rs +++ b/mindus/src/utils/image/mod.rs @@ -1,4 +1,3 @@ -use fast_image_resize as fr; pub use fimg::*; mod holder; @@ -14,8 +13,6 @@ pub trait ImageUtils { unsafe fn rotate(&mut self, times: u8) -> &mut Self; /// shadow fn shadow(&mut self) -> &mut Self; - /// scale a image - fn scale(self, to: u32) -> Image<Vec<u8>, 4>; } impl ImageUtils for Image<&mut [u8], 4> { @@ -39,23 +36,6 @@ impl ImageUtils for Image<&mut [u8], 4> { self } - // this function is very cold but im removing image so might as well use fir - fn scale(self, to: u32) -> Image<Vec<u8>, 4> { - let from = fr::Image::from_slice_u8( - self.width().try_into().unwrap(), - self.height().try_into().unwrap(), - self.take_buffer(), - fr::PixelType::U8x4, - ) - .unwrap(); - let toz = to.try_into().unwrap(); - let mut dst = fr::Image::new(toz, toz, fr::PixelType::U8x4); - fr::Resizer::new(fr::ResizeAlg::Nearest) - .resize(&from.view(), &mut dst.view_mut()) - .unwrap(); - Image::build(to, to).buf(dst.into_vec()) - } - fn shadow(&mut self) -> &mut Self { let mut shadow: Image<Vec<u8>, 4> = self.to_owned(); for [r, g, b, a] in shadow.chunked_mut() { |