[−][src]Crate qrcode_png
Create a QR code
use qrcode_png::{ColorType, Grayscale, QrCode, QrCodeEcc, RGB, RGBA}; let mut qrcode = QrCode::new(b"Hello Rust !", QrCodeEcc::Medium).unwrap(); qrcode.margin(10); qrcode.zoom(10); // -------- Grayscale let buf = qrcode .encode(ColorType::Grayscale(Grayscale::default())) .unwrap(); std::fs::write("./qrcode.grayscale.png", buf).unwrap(); // -------- RGB let buf = qrcode .encode(ColorType::RGB(RGB::new([3, 169, 244], [113, 140, 0]))) .unwrap(); std::fs::write("./qrcode.rgb.png", buf).unwrap(); // -------- RGBA let buf = qrcode .encode(ColorType::RGBA(RGBA::new( [137, 89, 168, 255], [255, 255, 255, 0], ))) .unwrap(); std::fs::write("./qrcode.rgba.png", buf).unwrap();
Structs
Grayscale | Grayscale 0-255 |
QrCode | Define QR code |
RGB | RGB color [0-255, 0-255, 0-255] |
RGBA | RGB color [0-255, 0-255, 0-255, 0-255] |
Enums
ColorType | PNG image color type |
QrCodeEcc | The error correction level in a QR Code symbol. |