Skip to content

RCasatta/bmp-monochrome

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

70 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.48

About

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

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages