Data Matrix (ECC 200) decoding and encoding library with an optimizing encoder.
This library features a new, 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 unique about this implementation. See the list of related projects below for credits and references to other open source Data Matrix libraries.
rust
let bitmap = datamatrix::encode(b"Hello, World!", SymbolSize::Min).unwrap();
print!("{}", bitmap.unicode()); // print "ASCII art" version
The library contains no noteworthy rendering. You have to write you own
renderer for whatever your desired output format is. 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 the using the heuristic (see open bugs in zxing). And, of course, there are cases where it will return a smaller symbol altough 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.