Skip to content

Commit

Permalink
updated zxing-cpp to v2.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
khoren93 committed Dec 9, 2023
1 parent 67d9fff commit 6d89045
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 6 deletions.
8 changes: 7 additions & 1 deletion lib/src/models/format.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ abstract class Format {
static const int upca = 1 << 14; // UPC-A (1D)
static const int upce = 1 << 15; // UPC-E (1D)
static const int microQRCode = 1 << 16; // Micro QR Code
static const int rmqrCode = 1 << 17; // Rectangular Micro QR Code

static const int linearCodes = codabar |
code39 |
Expand All @@ -33,7 +34,7 @@ abstract class Format {
upca |
upce;
static const int matrixCodes =
aztec | dataMatrix | maxiCode | pdf417 | qrCode | microQRCode;
aztec | dataMatrix | maxiCode | pdf417 | qrCode | microQRCode | rmqrCode;
static const int any = linearCodes | matrixCodes;
}

Expand All @@ -53,6 +54,7 @@ extension CodeFormat on int {
static final List<int> supportedEncodeFormats = <int>[
Format.qrCode,
// Format.microQRCode,
// Format.rmqrCode,
Format.dataMatrix,
Format.aztec,
// Format.pdf417,
Expand Down Expand Up @@ -90,6 +92,7 @@ final Map<int, String> barcodeNames = <int, String>{
Format.upca: 'UPCA',
Format.upce: 'UPCE',
Format.microQRCode: 'Micro QR Code',
Format.rmqrCode: 'Rectangular Micro QR Code',
Format.linearCodes: 'OneD',
Format.matrixCodes: 'TwoD',
Format.any: 'Any',
Expand All @@ -113,6 +116,7 @@ final Map<int, double> barcodeRatios = <int, double>{
Format.upca: 3.0 / 1.0, // recommended ratio: 3:1
Format.upce: 1.0 / 1.0, // recommended ratio: 1:1 (square)
Format.microQRCode: 3.0 / 3.0, // recommended ratio: 3:3 (square)
Format.rmqrCode: 3.0 / 3.0, // recommended ratio: 3:3 (square)
};

final Map<int, String> barcodeDemoText = <int, String>{
Expand All @@ -133,6 +137,7 @@ final Map<int, String> barcodeDemoText = <int, String>{
Format.upca: '72527273070',
Format.upce: '0123456',
Format.microQRCode: 'This is a Micro QR Code',
Format.rmqrCode: 'This is a Rectangular Micro QR Code',
};

final Map<int, int> barcodeMaxTextLengths = <int, int>{
Expand All @@ -153,4 +158,5 @@ final Map<int, int> barcodeMaxTextLengths = <int, int>{
Format.upca: 12,
Format.upce: 8,
Format.microQRCode: 4296,
Format.rmqrCode: 4296,
};
6 changes: 5 additions & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,8 @@ target_link_libraries(flutter_zxing ZXing)
if (ANDROID)
find_library(log-lib log)
target_link_libraries(flutter_zxing ${log-lib})
endif (ANDROID)
endif (ANDROID)

# Command to update zxing submodule
# cd src/zxing
# git checkout v2.2.0
6 changes: 3 additions & 3 deletions src/native_zxing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ extern "C"
char const *version()
{
// return ZXING_VERSION_STR; // TODO: Not working on iOS for now
return "2.1.0";
return "2.2.0";
}

FUNCTION_ATTRIBUTE
Expand All @@ -66,7 +66,7 @@ extern "C"
{
image = image.cropped(width / 2 - cropWidth / 2, height / 2 - cropHeight / 2, cropWidth, cropHeight);
}
DecodeHints hints = DecodeHints().setTryHarder(tryHarder).setTryRotate(tryRotate).setFormats(BarcodeFormat(format)).setTryInvert(tryInvert).setReturnErrors(true);
ReaderOptions hints = ReaderOptions().setTryHarder(tryHarder).setTryRotate(tryRotate).setFormats(BarcodeFormat(format)).setTryInvert(tryInvert).setReturnErrors(true);
Result result = ReadBarcode(image, hints);

delete[] bytes;
Expand All @@ -92,7 +92,7 @@ extern "C"
{
image = image.cropped(width / 2 - cropWidth / 2, height / 2 - cropHeight / 2, cropWidth, cropHeight);
}
DecodeHints hints = DecodeHints().setTryHarder(tryHarder).setTryRotate(tryRotate).setFormats(BarcodeFormat(format)).setTryInvert(tryInvert);
ReaderOptions hints = ReaderOptions().setTryHarder(tryHarder).setTryRotate(tryRotate).setFormats(BarcodeFormat(format)).setTryInvert(tryInvert);
Results results = ReadBarcodes(image, hints);
delete[] bytes;

Expand Down
2 changes: 1 addition & 1 deletion src/zxing
Submodule zxing updated 200 files

0 comments on commit 6d89045

Please sign in to comment.