tpt-barcode

Rust

Zero-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_std compatible, perspective-corrected QR scanning, pure MIT dependency chain.

Crates.io Docs.rs CI License: MIT OR Apache-2.0

Features

  • True zero-allocation scanning — perspective correction uses tpt-math-linalg-fixed for compile-time-known 3×3 matrix inversion with no heap allocation.
  • no_std throughout — every crate supports no_std + alloc; std is 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 licenseMIT 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

CrateDescriptionno_std
tpt-barcode-coreGF(256) (0x11D + 0x12D), Reed-Solomon error correction, shared traitsyes
tpt-barcode-1dCode 128, EAN-13, UPC-A, Code 39yes
tpt-barcode-2dQR Code, DataMatrix, PDF417yes
tpt-barcode-imageAdaptive binarization, finder detection, homographyyes
tpt-barcode-renderSVG, PNG, ANSI terminal outputstd
tpt-barcodeFacade — re-exports all crates via feature flagsopt-in

Feature Flags

[dependencies]
tpt-barcode = { version = "0.1", default-features = false, features = ["alloc", "2d"] }
FlagDefaultDescription
stdyesEnable standard library support
allocvia stdEnable heap allocation (no_std + alloc)
1dyesInclude 1D symbologies
2dyesInclude 2D symbologies (QR, DataMatrix, PDF417)
scanyesInclude image scanning pipeline
renderyesInclude output renderers
simdnoSIMD-accelerated binarization (SSE2 threshold stage)
pngnoPNG output via image crate

License

Licensed under either of:

at your option.

Copyright 2025 TPT Solutions.