Crates.io | datamatrix |
lib.rs | datamatrix |
version | 0.3.2 |
source | src |
created_at | 2021-01-24 11:18:23.651552 |
updated_at | 2024-11-17 14:13:51.021464 |
description | Data Matrix (ECC 200) decoding and encoding with an optimizing encoder |
homepage | |
repository | https://github.com/jannschu/datamatrix-rs/ |
max_upload_size | |
id | 345984 |
size | 348,785 |
Data Matrix (ECC 200) decoding and encoding library with an optimizing encoder.
This library features an optimzing, and linear time encoder which achieves the smallest possible encoding size.
The Data Matrix standard (ISO/IEC 16022:2006) contains a heuristic to decide which encoding modes to use, and in most cases that works. A straightforward implementation will not have linear runtime, though. This library uses an idea similar to the A* algorithm.
The optimizer is special about this implementation, most implementations use the heuristic. See the list of related projects below for credits and references to other open source Data Matrix libraries.
let code = DataMatrix::encode(
b"Hello, World!",
SymbolList::default(),
).unwrap();
// print an "ASCII art" version
print!("{}", code.bitmap().unicode());
The library contains helpers for generating other output formats. Example code can be found
in examples/
. The extra effort for this last rendering step is usually low and
this approach allows high flexibility.
Things in consideration for after that:
Since the encoded data is padded to fill up the remaining space in a Data Matrix symbol, the symbol generated by this library will in many cases not be smaller compared to an optimizer based on the heuristic defined in the specification. What it achieves however in any case is a linear encoding time, and it avoids some of the bugs which can be attributed to using the heuristic (see open bugs in zxing and OkapiBarcode). And, of course, there are cases where it will return a smaller symbol although admittedly no thorough study of this has been done.
The following projects were invaluable for learning from their implementation and stealing some of their test cases and bug reports.