z2oh

Untitled

Mar 7th, 2018
167
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Rust 0.63 KB | None | 0 0
  1. extern crate image;
  2.  
  3. use image::GenericImage;
  4.  
  5. use std::path::Path;
  6. use std::fs::File;
  7.  
  8. fn main() {
  9.     let (img_x, img_y) = (9 * (7 + 17) + 17, 210 + 17 + 17);
  10.     let mut img_buf = image::ImageBuffer::new(img_x, img_y);
  11.  
  12.     for (x, y, rgb) in img_buf.enumerate_pixels_mut() {
  13.         *rgb = image::Rgba([0, 0, 0, 255]);
  14.         if x > 17 && (x - 17) % (7 + 17) < 7 && y > 17 && y < 210 + 17 {
  15.             *rgb = image::Rgba([255, 255, 255, 255]);
  16.         }
  17.     }
  18.  
  19.     let fout = &mut File::create(Path::new("/home/jaday/school/763/hw4prog/img.png")).unwrap();
  20.     image::ImageRgba8(img_buf).save(fout, image::PNG).unwrap();
  21. }
Advertisement
Add Comment
Please, Sign In to add comment