5 releases
0.2.0 | Apr 18, 2020 |
---|---|
0.1.3 | Apr 18, 2020 |
0.1.2 | Apr 18, 2020 |
0.1.1 | Apr 18, 2020 |
0.1.0 | Apr 18, 2020 |
#929 in Images
7KB
122 lines
#Geefr's PPM lib
This crate provides a PPM writer, originally written for the 'ray tracing in a weekend' series.
Currently supports files in 'P3' format, and max pixel value of 255 (u8). No limits on width/height.
#Reading a PPM
use geefr_ppm::Ppm;
// Load from file
let ppm = Ppm::read(String::from("foo.ppm")).expect("Failed to load PPM");
// Get a pixel
// origin is top-left
let (r,g,b) = ppm.get_pixel(x, y);
#Creating a PPM
use geefr_ppm::Ppm;
// Create a ppm
let mut ppm = Ppm::new(width, height);
// Set a pixel
// origin is top-left
// r, g, b are 0-255 (u8)
ppm.set_pixel(x, y, r, g, b);
// Save to a file
ppm.write(String::from("foo.ppm")).expect("Failed to save PPM");