ductr

Crates.ioductr
lib.rsductr
version0.0.1
sourcesrc
created_at2022-12-23 11:22:04.209244
updated_at2022-12-23 11:22:04.209244
descriptiona small crate for reading, writing, and simple manipulation of the portable pixelmap format family
homepage
repositoryhttps://github.com/KairosJK/ductr
max_upload_size
id744465
size64,682
Jonathan Koฤevar (KairosJK)

documentation

README

๐ŸŽจ Ductr

a small struct crate for reading, writing, and simple manipulation of the portable pixelmap format family

๐Ÿง  Design

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

๐Ÿ–ฅ๏ธ How to use:

The following crate can be used by entering the following in your project's Cargo.toml file:

[dependencies]
ductr = "0.0.1"

โš™๏ธ Examples

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");

๐Ÿ“Œ Other Information on the format

๐Ÿ‘ค Authored by

Jonathan Kocevar

๐Ÿ“ License

This project is licensed under the terms of the GNU General Public License v3.0.

Commit count: 9

cargo fmt