Skip to content

(WIP) 🖼 Light-weight bitmaps' encoding library written by Rust.

License

Notifications You must be signed in to change notification settings

ShZh-libraries/szimg

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

szimg

Light weight image library which focus on plotting!

Overview

type cargo run --example <example_name> in your terminal to see these example images crafted by our library.

mandlebrot julia_set barnsley_fern
mandlebrot julia_set barnsley_fern

Usage

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.

Roadmap

  • Netpbm
  • PNG
  • JPEG
  • GIF
  • BMP
  • TIFF
  • AVIF

All pull requests of other format images are welcome.

License

Apache-2.0 License

Copyright (©) 2021 Sh-Zh-7

Releases

No releases published

Packages

No packages published