Crates.io | ductr |
lib.rs | ductr |
version | 0.0.1 |
source | src |
created_at | 2022-12-23 11:22:04.209244 |
updated_at | 2022-12-23 11:22:04.209244 |
description | a small crate for reading, writing, and simple manipulation of the portable pixelmap format family |
homepage | |
repository | https://github.com/KairosJK/ductr |
max_upload_size | |
id | 744465 |
size | 64,682 |
a small struct crate for reading, writing, and simple manipulation of the portable pixelmap format family
This crate was made with the focus of quick and easy debugging as its main goal. Printing byte arrays quickly to a visual file can be great when debugging basic graphics and image manipulation algorithms, and the Portable pixelmap family format is one of the quickest to set up.
In the future this crate may extend to other raster file formats, such as JPEG or BMP
The following crate can be used by entering the following in your project's Cargo.toml
file:
[dependencies]
ductr = "0.0.1"
use ductr::AnymapImage;
// Creating a 100x100 black pbm image
// Prepare buffer to be written to pbm format
let buffer = vec![1; 100*100];
// Create AnymapImage object with pbm constructor
let pbm_black = AnymapImage::pbm(buffer, 100, 100).unwrap();
// Write pbm as binary file
pbm_black.write_as_binary("pbm_black_binary.pbm").expect("Error: could not to binary file.");
use ductr::AnymapImage;
// Inverting the colors of a given ppm image
// Create AnymapImage object from binary ppm image file
let mut cat = AnymapImage::read_from_binary("tests/images/cat_binary.ppm").expect("Error: could not read from binary file");
// Invert the image
cat.invert();
// Write ppm as binary file
cat.write_as_binary("tests/images/cat_inverted.pnm").expect("Error: could not write to binary file");
@Tsoding - "Procedural Graphics in C" for highlighting the utility of a simple format such as the ppm family for easier graphics debugging
Jonathan Kocevar
This project is licensed under the terms of the GNU General Public License v3.0.