make_png now utilizes image_to_cursor
authorMegaBrutal <code+git@megabrutal.com>
Mon, 18 Jul 2022 00:40:30 +0000 (02:40 +0200)
committerMegaBrutal <code+git@megabrutal.com>
Mon, 18 Jul 2022 00:40:30 +0000 (02:40 +0200)
src/main.rs

index 55d89fe382dd2711f3a0126c9c650f07070e0073..e1c238a272a00a14dca9ac4819c72faca6c77b66 100644 (file)
@@ -212,12 +212,7 @@ fn make_png(dim_x: u32, dim_y: u32, scale: u32, data: &mut dyn Iterator<Item = u
     }
 
     let img: RgbImage = rgb_encode(ImageBuffer::new(dim_x, dim_y), data)?;
-
-    let tdim_x = dim_x * scale;
-    let tdim_y = dim_y * scale;
-    let img = resize(&img, tdim_x, tdim_y, FilterType::Nearest);
-    let mut cursor = Cursor::new(Vec::new());
-    to_imageresult(write_buffer_with_format(&mut cursor, &img, tdim_x, tdim_y, ColorType::Rgb8, Png))?;
+    let cursor = image_to_cursor(img, scale)?;
     Ok(cursor)
 }