bmp-monochrome

Crates.iobmp-monochrome
lib.rsbmp-monochrome
version1.1.0
sourcesrc
created_at2020-09-28 15:58:59.013605
updated_at2023-05-09 09:49:54.437348
descriptionEncode and decode monochromatic bitmaps without additional dependencies, useful for QR codes.
homepagehttps://github.com/RCasatta/bmp-monochrome
repositoryhttps://github.com/RCasatta/bmp-monochrome
max_upload_size
id293743
size55,108
Riccardo Casatta (RCasatta)

documentation

https://docs.rs/bmp-monochrome/

README

bmp-monochrome

crates.io

Encode and decode monochromatic bitmaps without additional dependencies, useful for QR codes.

Example

use bmp_monochrome::Bmp;
use std::error::Error;
use std::fs::File;

fn main() -> Result<(), Box<dyn Error>> {
    let file_name = "test.bmp";
    let width = 21;
    let data: Vec<bool> = (0..width * width).map(|e| e % 2 == 0).collect();
    let rows: Vec<Vec<bool>> = data.chunks(width).map(|e| e.to_vec()).collect();
    let bmp = Bmp::new(rows)?;
    bmp.write(File::create(file_name)?)?;
    let bmp_read = Bmp::read(File::open(file_name)?)?;
    assert_eq!(bmp, bmp_read);
    Ok(())
}

Generates

test

Minimum Supported Rust Version (MSRV)

Rust 1.34

Use u32::try_from introduced in 1.34.0

Commit count: 70

cargo fmt