Actively use image library for exporting

This commit is contained in:
Jonathan Flueren 2022-05-05 13:33:06 +02:00
parent 69b77db716
commit 223ac1eb24

View file

@ -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!");
}