#qrcode #codec #monochrome #bitmap #bmp #codes #monochromatic

bmp-monochrome

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

17 releases (2 stable)

1.1.0 May 9, 2023
1.0.0 Oct 28, 2020
0.17.0 Oct 25, 2020

#5 in #monochrome

Download history 676/week @ 2024-07-26 322/week @ 2024-08-02 323/week @ 2024-08-09 199/week @ 2024-08-16 372/week @ 2024-08-23 437/week @ 2024-08-30 571/week @ 2024-09-06 270/week @ 2024-09-13 378/week @ 2024-09-20 381/week @ 2024-09-27 377/week @ 2024-10-04 506/week @ 2024-10-11 364/week @ 2024-10-18 222/week @ 2024-10-25 272/week @ 2024-11-01 227/week @ 2024-11-08

1,167 downloads per month
Used in 17 crates (via qr_code)

MIT license

36KB
813 lines

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


lib.rs:

BMP monochrome

This library encode and decode monochromatic bitmap with no extra dependencies. Especially useful to encode QR-codes

Dependencies

~0–600KB
~13K SLoC