ft: 2.1+2.2: image output

This commit is contained in:
djaidjai committed 2026-04-14 22:56:11 +02:00
commit 6787bb5cfd
5 files changed
+1029

No files matched your search

+23
View 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
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.