Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I procedurally generate images using rust-image?

I'd like to learn Rust and thought it would be fun to procedurally generate images. I've no idea where to start though... piston/rust-image? But even with that where should I begin?

like image 625
Rik Avatar asked Apr 24 '15 00:04

Rik


1 Answers

As @huon answer is 6 years old, I was getting errors reproducing the result, so I wrote this,

use image::{ImageBuffer, RgbImage};

const WIDTH:u32 = 10;
const HEIGHT:u32 = 10;

fn main() {
    let mut image: RgbImage = ImageBuffer::new(WIDTH, HEIGHT);
    *image.get_pixel_mut(5, 5) = image::Rgb([255,255,255]);
    image.save("output.png").unwrap();
}
like image 117
Eka Avatar answered Oct 13 '22 00:10

Eka