defaultAztecReader function
The default Aztec decoder using AztecReader.
It is considered pretty unreliably about the binary encoding. You should rather specify as custom one.
Implementation
Uint8List? defaultAztecReader(Image image) {
final squareBytes = image.buffer.asUint8List();
final pixels = Uint8List(image.width * image.height);
for (int i = 0; i < pixels.length; i++) {
pixels[i] = _getLuminanceSourcePixel(squareBytes, i * 4);
}
final imageSource = RGBLuminanceSource(
image.width,
image.height,
squareBytes,
);
final bitmap = BinaryBitmap(HybridBinarizer(imageSource));
final reader = AztecReader();
final result = reader.decode(
bitmap,
DecodeHint(tryHarder: true, alsoInverted: true),
);
final bytes = result.rawBytes;
if (bytes == null) return null;
return Uint8List.fromList(bytes);
}