tpt-barcode
RustZero-allocation barcode generation and scanning for Rust — no_std compatible, perspective-corrected QR scanning, pure MIT/Apache dependency chain.
0 stars0 forks0 watchers
Languages
Rust100.0%
README
tpt-barcode
Zero-allocation barcode generation and scanning for Rust —
no_stdcompatible, perspective-corrected QR scanning, pure MIT dependency chain.
Features
- True zero-allocation scanning — perspective correction uses
tpt-math-linalg-fixedfor compile-time-known 3×3 matrix inversion with no heap allocation. no_stdthroughout — every crate supportsno_std + alloc;stdis an opt-in feature.- Symbology coverage — QR Code (encode + decode, v1–40), DataMatrix ECC 200 (encode + decode), Code 128, EAN-13, UPC-A, Code 39. PDF417 is scaffolding only (see the changelog).
- Conformance-anchored — QR and DataMatrix output verified matrix-for-matrix against reference implementations (
qrcode, libdmtx); QR decoding verified against ISO-conformant foreign symbols. - Dual license —
MIT OR Apache-2.0.
Quick Start
[dependencies]
tpt-barcode = "0.1"
Generate a QR code
use tpt_barcode::prelude::*;
let qr = tpt_barcode::qr::encode("https://github.com/tpt-solutions", EcLevel::M)?;
let svg = tpt_barcode::render::svg::SvgBuilder::new(&qr.matrix, qr.size)
.module_size(4)
.build();
Scan an image
use tpt_barcode::core::Format;
let img = image::open("skewed_qr.jpg")?.into_luma8();
let results = tpt_barcode::scan(img.as_raw(), img.width() as usize, img.height() as usize)
.formats(&[Format::QrCode])
.try_harder(true)
.execute()?;
for result in results {
println!("Decoded: {} ({:?})", result.text(), result.format());
let corners = result.bounding_box();
println!("Corners: {:?}", corners);
}
Workspace Crates
| Crate | Description | no_std |
|---|---|---|
tpt-barcode-core | GF(256) (0x11D + 0x12D), Reed-Solomon error correction, shared traits | yes |
tpt-barcode-1d | Code 128, EAN-13, UPC-A, Code 39 | yes |
tpt-barcode-2d | QR Code, DataMatrix, PDF417 | yes |
tpt-barcode-image | Adaptive binarization, finder detection, homography | yes |
tpt-barcode-render | SVG, PNG, ANSI terminal output | std |
tpt-barcode | Facade — re-exports all crates via feature flags | opt-in |
Feature Flags
[dependencies]
tpt-barcode = { version = "0.1", default-features = false, features = ["alloc", "2d"] }
| Flag | Default | Description |
|---|---|---|
std | yes | Enable standard library support |
alloc | via std | Enable heap allocation (no_std + alloc) |
1d | yes | Include 1D symbologies |
2d | yes | Include 2D symbologies (QR, DataMatrix, PDF417) |
scan | yes | Include image scanning pipeline |
render | yes | Include output renderers |
simd | no | SIMD-accelerated binarization (SSE2 threshold stage) |
png | no | PNG output via image crate |
License
Licensed under either of:
- MIT license (LICENSE-MIT)
- Apache License, Version 2.0 (LICENSE-APACHE)
at your option.
Copyright 2025 TPT Solutions.