From 223ac1eb244151db34a11bbd0c1dc3b42842a073 Mon Sep 17 00:00:00 2001 From: Jonathan Flueren Date: Thu, 5 May 2022 13:33:06 +0200 Subject: [PATCH] Actively use image library for exporting --- src/main.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/main.rs b/src/main.rs index b0e9c4a..e497ea6 100644 --- a/src/main.rs +++ b/src/main.rs @@ -72,10 +72,10 @@ fn main() { default_file = &args[1]; } - //let mut image = RgbImage::new(image_width, image_height); + let mut image = RgbImage::new(image_width, image_height); - let mut file = BufWriter::new(File::create(default_file).unwrap()); - writeln!(&mut file, "P3\n{image_width} {image_height}\n255\n").unwrap(); + //let mut file = BufWriter::new(File::create(default_file).unwrap()); + //writeln!(&mut file, "P3\n{image_width} {image_height}\n255\n").unwrap(); for j in (0..image_height).rev() { eprint!("\rScanlines remaining: {j:5}"); @@ -88,11 +88,11 @@ fn main() { ); let pixel_color = ray_color(&r, &mut world); - color::write_color(&mut file, &pixel_color); - //color::put_color(&mut image, &pixel_color, image_width-i-1, image_height-j-1); + //color::write_color(&mut file, &pixel_color); + color::put_color(&mut image, &pixel_color, image_width-i-1, image_height-j-1); } } - //image.save(default_file).unwrap(); + image.save(default_file).unwrap(); eprintln!("\nDone!"); }