Skip to content
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