Light weight image library which focus on plotting!
type cargo run --example <example_name>
in your terminal to see these example images crafted by our library.
mandlebrot | julia_set | barnsley_fern |
To save a specified format image file, you need to prepare your data in Rust's raw multi-dimension array. That is because each channel data of your image file must have same size(both width and height). With raw array Rust compiler can easily check if your data have satisfied this constraint.
For example, if you want to save a PNG format file:
use szimg::png::save_png;
fn main() {
let mut png_array = [[[0_u8; 3]; 255]; 255];
for outer_index in 0..255 {
for inner_index in 0..255 {
png_array[outer_index][inner_index][0] = outer_index as u8;
png_array[outer_index][inner_index][1] = inner_index as u8;
png_array[outer_index][inner_index][2] = 128;
}
}
save_png("rgb.png", png_array).unwrap();
}
You will get:
For more exmaples you can check the test folder. In the near future the cargo doument will be supported as well.
- Netpbm
- PNG
- JPEG
- GIF
- BMP
- TIFF
- AVIF
All pull requests of other format images are welcome.
Copyright (©) 2021 Sh-Zh-7