From 1bab092956358d9949b54260afd663efed2e0319 Mon Sep 17 00:00:00 2001 From: cyrgani Date: Thu, 27 Mar 2025 10:59:55 +0100 Subject: [PATCH] stop flipping the image in `Image::export_png` --- src/texture.rs | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/src/texture.rs b/src/texture.rs index c31c3e66..919242a6 100644 --- a/src/texture.rs +++ b/src/texture.rs @@ -304,19 +304,9 @@ impl Image { /// Saves this image as a PNG file. /// This method is not supported on web and will panic. pub fn export_png(&self, path: &str) { - let mut bytes = vec![0; self.width as usize * self.height as usize * 4]; - - // flip the image before saving - for y in 0..self.height as usize { - for x in 0..self.width as usize * 4 { - bytes[y * self.width as usize * 4 + x] = - self.bytes[(self.height as usize - y - 1) * self.width as usize * 4 + x]; - } - } - image::save_buffer( path, - &bytes[..], + &self.bytes, self.width as _, self.height as _, image::ColorType::Rgba8,