ft: 2.1+2.2: image output
This commit is contained in:
23
src/main.rs
Normal file
23
src/main.rs
Normal file
@@ -0,0 +1,23 @@
|
||||
fn main() {
|
||||
let image_width = 256;
|
||||
let image_height = 256;
|
||||
|
||||
let mut imgbuf = image::ImageBuffer::new(image_width, image_height);
|
||||
|
||||
for j in 0..image_height {
|
||||
for i in 0..image_width {
|
||||
let r = i as f32 / (image_width - 1) as f32;
|
||||
let g = j as f32 / (image_height - 1) as f32;
|
||||
let b = 0.0;
|
||||
|
||||
let ir = (255.599 * r) as u8;
|
||||
let ig = (255.599 * g) as u8;
|
||||
let ib = (255.599 * b) as u8;
|
||||
|
||||
let pixel = imgbuf.get_pixel_mut(i, j);
|
||||
*pixel = image::Rgb([ir, ig, ib]);
|
||||
}
|
||||
}
|
||||
|
||||
imgbuf.save("output.png").unwrap();
|
||||
}
|
||||
Reference in New Issue
Block a user