Skip to content

RCasatta/qr_code

Repository files navigation

qr_code

crates.io MIT OR Apache 2.0

QR code encoder and decoder [*] in Rust. Documentation.

Encoder

This lib forked https://docs.rs/qrcode mainly because of lack of support to structured QR code (multiple QR codes) even if the minimal change required has been pushed kennytm/qrcode-rust#44

Moreover dependencies image, checked_int_cast and module render has been removed with a view to simplicity.

Decoder [*]

Decoder part is based on https://docs.rs/rqrr/0.3.0/rqrr/ without the image detection part and is not intended for scanning QR codes from camera.

Decoder is included only for testing purpose, so that depending libraries could run round trip during tests.

Example

Bmp image generation

requires bmp feature

let qr_code = qr_code::QrCode::new(b"Hello").unwrap();
let bmp = qr_code.to_bmp();
bmp.write(std::fs::File::create("test.bmp").unwrap()).unwrap();

Generate this image:

test

Looks small?

Many context supports rescaling mode specific for pixelated images, for example in html image-rendering: pixelated;

As an alternative see method Bmp::mul and Bmp::add_whitespace

Unicode string generation

let qr_code = qr_code::QrCode::new(b"Hello").unwrap();
println!("{}", qr_code.to_string(false, 3));

Generates this output (looks better in terminal):

                           
                           
   █▀▀▀▀▀█  ▀▀▀█ █▀▀▀▀▀█   
   █ ███ █ █ █ ▀ █ ███ █   
   █ ▀▀▀ █ ██ ▄▀ █ ▀▀▀ █   
   ▀▀▀▀▀▀▀ █ █ ▀ ▀▀▀▀▀▀▀   
   ▀ ▀█▀▀▀ ▄▀ █▄▄█▀▀██ ▄   
     █▀▀█▀▄▄▀█▄█▄█▀ ██▀    
    ▀▀▀  ▀▀█▀▀ █  █ ▄  ▀   
   █▀▀▀▀▀█ ▄▀▄▀ ▀ ▄█▄██    
   █ ███ █ █▄ █▄█▄▄▀▄ ▀    
   █ ▀▀▀ █ ▀█ ▄█▄█▀▄▄█     
   ▀▀▀▀▀▀▀ ▀▀  ▀   ▀  ▀    
                           

Minimum Supported Rust Version (MSRV)

Current MSRV is 1.48.0

About

No description, website, or topics provided.

Resources

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE.txt
MIT
LICENSE-MIT.txt

Stars

Watchers

Forks

Packages

No packages published

Languages