BMP Rust
BMP Rust is a pure rust library to read and write .bmp Image files. It has zero dependencies.
Besides the basic reading pixel color and changing pixel color, various filters, blurs, and shapes are implemented. The library can also parse the file header, DIB header and other parts of the file. Many useful utility functions are also included.
Install
Obviously, install Rust. Add bmp-rust to your Cargo.toml file:
[]
="0.4.0"
You can now use the crate:
use BMP;
Documentation
The docs.rs page contains documentation for all functions and types in this library.
First, load a BMP file by file path, or create a new one:
let mut bmp_from_file = BMP new_from_file;
let mut bmp_from_scratch = BMP new;
Information can now be read from the file:
let file_size = bmp_from_file.get_size;
let dib_header = bmp_from_file.get_dib_header.unwrap;
let width = dib_header.width;
let height = dib_header.height;
let pixel_color = bmp_from_file.get_color_of_px.unwrap;
Or new pixel data can be written to it:
bmp_from_file.change_color_of_pixel.expect;
bmp_from_file.fill_bucket.expect;
bmp_from_file.draw_line.expect;
bmp_from_file.draw_rectangle.expect;
bmp_from_file.draw_ellipse.expect;
bmp_from_file.invert.expect;
bmp_from_file.change_opacity.expect;
bmp_from_file.draw_image.expect;
bmp_from_file.translate;
bmp_from_file.gaussian_blur.expect;
Finally, the modified file can be saved to a file:
bmp_from_file.save_to_new.expect;
Look at the source code or tests/example for more functions, and their usage.