Skip to content

stop flipping the image in Image::export_png #929

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 1 addition & 11 deletions src/texture.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Loading