react-native-nitro-zxing 0.1.0-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +34 -0
- package/VisionCameraZxing.podspec +48 -0
- package/android/CMakeLists.txt +43 -0
- package/android/build.gradle +150 -0
- package/android/fix-prefab.gradle +51 -0
- package/android/gradle.properties +5 -0
- package/android/src/main/AndroidManifest.xml +3 -0
- package/android/src/main/cpp/cpp-adapter.cpp +7 -0
- package/android/src/main/java/com/margelo/nitro/camera/zxing/VisionCameraZxingPackage.kt +21 -0
- package/cpp/BarcodeValueTypeClassifier.cpp +70 -0
- package/cpp/BarcodeValueTypeClassifier.hpp +14 -0
- package/cpp/FrameImageView.cpp +75 -0
- package/cpp/FrameImageView.hpp +34 -0
- package/cpp/HybridBarcode.cpp +59 -0
- package/cpp/HybridBarcode.hpp +26 -0
- package/cpp/HybridBarcodeScanner.cpp +121 -0
- package/cpp/HybridBarcodeScanner.hpp +26 -0
- package/cpp/HybridBarcodeScannerFactory.cpp +11 -0
- package/cpp/HybridBarcodeScannerFactory.hpp +14 -0
- package/cpp/ImageDownscaler.cpp +34 -0
- package/cpp/ImageDownscaler.hpp +21 -0
- package/cpp/ZXingDecoder.cpp +189 -0
- package/cpp/ZXingDecoder.hpp +72 -0
- package/cpp/zxing-core/LICENSE +202 -0
- package/cpp/zxing-core/README.md +156 -0
- package/cpp/zxing-core/core/CMakeLists.txt +784 -0
- package/cpp/zxing-core/core/Version.h.in +28 -0
- package/cpp/zxing-core/core/ZXingConfig.cmake.in +9 -0
- package/cpp/zxing-core/core/src/Barcode.cpp +255 -0
- package/cpp/zxing-core/core/src/Barcode.h +191 -0
- package/cpp/zxing-core/core/src/BarcodeData.h +100 -0
- package/cpp/zxing-core/core/src/BarcodeFormat.cpp +286 -0
- package/cpp/zxing-core/core/src/BarcodeFormat.h +272 -0
- package/cpp/zxing-core/core/src/BinaryBitmap.cpp +111 -0
- package/cpp/zxing-core/core/src/BinaryBitmap.h +66 -0
- package/cpp/zxing-core/core/src/BitArray.cpp +38 -0
- package/cpp/zxing-core/core/src/BitArray.h +181 -0
- package/cpp/zxing-core/core/src/BitMatrix.cpp +175 -0
- package/cpp/zxing-core/core/src/BitMatrix.h +199 -0
- package/cpp/zxing-core/core/src/BitMatrixCursor.h +253 -0
- package/cpp/zxing-core/core/src/BitMatrixIO.cpp +101 -0
- package/cpp/zxing-core/core/src/BitMatrixIO.h +21 -0
- package/cpp/zxing-core/core/src/BitSource.cpp +77 -0
- package/cpp/zxing-core/core/src/BitSource.h +72 -0
- package/cpp/zxing-core/core/src/ByteArray.h +42 -0
- package/cpp/zxing-core/core/src/CharacterSet.cpp +78 -0
- package/cpp/zxing-core/core/src/CharacterSet.h +58 -0
- package/cpp/zxing-core/core/src/ConcentricFinder.cpp +312 -0
- package/cpp/zxing-core/core/src/ConcentricFinder.h +156 -0
- package/cpp/zxing-core/core/src/Content.cpp +471 -0
- package/cpp/zxing-core/core/src/Content.h +82 -0
- package/cpp/zxing-core/core/src/ContentType.h +19 -0
- package/cpp/zxing-core/core/src/CreateBarcode.cpp +490 -0
- package/cpp/zxing-core/core/src/CreateBarcode.h +132 -0
- package/cpp/zxing-core/core/src/DecoderResult.h +92 -0
- package/cpp/zxing-core/core/src/DetectorResult.h +44 -0
- package/cpp/zxing-core/core/src/ECI.cpp +81 -0
- package/cpp/zxing-core/core/src/ECI.h +78 -0
- package/cpp/zxing-core/core/src/Error.cpp +29 -0
- package/cpp/zxing-core/core/src/Error.h +79 -0
- package/cpp/zxing-core/core/src/Flags.h +165 -0
- package/cpp/zxing-core/core/src/GTIN.cpp +253 -0
- package/cpp/zxing-core/core/src/GTIN.h +58 -0
- package/cpp/zxing-core/core/src/GlobalHistogramBinarizer.cpp +197 -0
- package/cpp/zxing-core/core/src/GlobalHistogramBinarizer.h +34 -0
- package/cpp/zxing-core/core/src/GridSampler.cpp +124 -0
- package/cpp/zxing-core/core/src/GridSampler.h +59 -0
- package/cpp/zxing-core/core/src/HRI.cpp +343 -0
- package/cpp/zxing-core/core/src/HRI.h +16 -0
- package/cpp/zxing-core/core/src/HybridBinarizer.cpp +315 -0
- package/cpp/zxing-core/core/src/HybridBinarizer.h +40 -0
- package/cpp/zxing-core/core/src/ImageView.h +168 -0
- package/cpp/zxing-core/core/src/JSON.cpp +154 -0
- package/cpp/zxing-core/core/src/JSON.h +66 -0
- package/cpp/zxing-core/core/src/LocalGrid.cpp +242 -0
- package/cpp/zxing-core/core/src/LocalGrid.h +91 -0
- package/cpp/zxing-core/core/src/LogMatrix.h +105 -0
- package/cpp/zxing-core/core/src/Matrix.h +125 -0
- package/cpp/zxing-core/core/src/MultiFormatReader.cpp +107 -0
- package/cpp/zxing-core/core/src/MultiFormatReader.h +34 -0
- package/cpp/zxing-core/core/src/MultiFormatWriter.cpp +111 -0
- package/cpp/zxing-core/core/src/MultiFormatWriter.h +62 -0
- package/cpp/zxing-core/core/src/Pattern.h +472 -0
- package/cpp/zxing-core/core/src/PerspectiveTransform.cpp +81 -0
- package/cpp/zxing-core/core/src/PerspectiveTransform.h +47 -0
- package/cpp/zxing-core/core/src/Point.h +185 -0
- package/cpp/zxing-core/core/src/Quadrilateral.h +215 -0
- package/cpp/zxing-core/core/src/Range.h +112 -0
- package/cpp/zxing-core/core/src/ReadBarcode.cpp +335 -0
- package/cpp/zxing-core/core/src/ReadBarcode.h +33 -0
- package/cpp/zxing-core/core/src/Reader.h +32 -0
- package/cpp/zxing-core/core/src/ReaderOptions.h +210 -0
- package/cpp/zxing-core/core/src/ReedSolomon.cpp +100 -0
- package/cpp/zxing-core/core/src/ReedSolomon.h +66 -0
- package/cpp/zxing-core/core/src/RegressionLine.h +161 -0
- package/cpp/zxing-core/core/src/ResultPoint.cpp +20 -0
- package/cpp/zxing-core/core/src/ResultPoint.h +35 -0
- package/cpp/zxing-core/core/src/StdGenerator.h +121 -0
- package/cpp/zxing-core/core/src/StdPrint.h +38 -0
- package/cpp/zxing-core/core/src/StdScope.h +55 -0
- package/cpp/zxing-core/core/src/StructuredAppend.h +19 -0
- package/cpp/zxing-core/core/src/SymbologyIdentifier.h +29 -0
- package/cpp/zxing-core/core/src/TextDecoder.cpp +59 -0
- package/cpp/zxing-core/core/src/TextDecoder.h +23 -0
- package/cpp/zxing-core/core/src/TextEncoder.cpp +75 -0
- package/cpp/zxing-core/core/src/TextEncoder.h +31 -0
- package/cpp/zxing-core/core/src/ThresholdBinarizer.h +58 -0
- package/cpp/zxing-core/core/src/TritMatrix.h +29 -0
- package/cpp/zxing-core/core/src/Utf.cpp +276 -0
- package/cpp/zxing-core/core/src/Utf.h +26 -0
- package/cpp/zxing-core/core/src/WhiteRectDetector.cpp +276 -0
- package/cpp/zxing-core/core/src/WhiteRectDetector.h +36 -0
- package/cpp/zxing-core/core/src/WriteBarcode.cpp +213 -0
- package/cpp/zxing-core/core/src/WriteBarcode.h +72 -0
- package/cpp/zxing-core/core/src/ZXAlgorithms.h +353 -0
- package/cpp/zxing-core/core/src/ZXConfig.h +17 -0
- package/cpp/zxing-core/core/src/ZXTestSupport.h +9 -0
- package/cpp/zxing-core/core/src/ZXVersion.h +14 -0
- package/cpp/zxing-core/core/src/ZXingC.cpp +460 -0
- package/cpp/zxing-core/core/src/ZXingC.h +296 -0
- package/cpp/zxing-core/core/src/ZXingCpp.cpp +18 -0
- package/cpp/zxing-core/core/src/ZXingCpp.h +76 -0
- package/cpp/zxing-core/core/src/ZXingQt.h +606 -0
- package/cpp/zxing-core/core/src/aztec/AZDecoder.cpp +376 -0
- package/cpp/zxing-core/core/src/aztec/AZDecoder.h +20 -0
- package/cpp/zxing-core/core/src/aztec/AZDetector.cpp +508 -0
- package/cpp/zxing-core/core/src/aztec/AZDetector.h +25 -0
- package/cpp/zxing-core/core/src/aztec/AZDetectorResult.h +51 -0
- package/cpp/zxing-core/core/src/aztec/AZEncoder.cpp +318 -0
- package/cpp/zxing-core/core/src/aztec/AZEncoder.h +44 -0
- package/cpp/zxing-core/core/src/aztec/AZEncodingState.h +40 -0
- package/cpp/zxing-core/core/src/aztec/AZHighLevelEncoder.cpp +377 -0
- package/cpp/zxing-core/core/src/aztec/AZHighLevelEncoder.h +36 -0
- package/cpp/zxing-core/core/src/aztec/AZReader.cpp +45 -0
- package/cpp/zxing-core/core/src/aztec/AZReader.h +21 -0
- package/cpp/zxing-core/core/src/aztec/AZToken.cpp +44 -0
- package/cpp/zxing-core/core/src/aztec/AZToken.h +39 -0
- package/cpp/zxing-core/core/src/aztec/AZWriter.cpp +38 -0
- package/cpp/zxing-core/core/src/aztec/AZWriter.h +55 -0
- package/cpp/zxing-core/core/src/datamatrix/DMBitLayout.cpp +194 -0
- package/cpp/zxing-core/core/src/datamatrix/DMBitLayout.h +21 -0
- package/cpp/zxing-core/core/src/datamatrix/DMDataBlock.cpp +63 -0
- package/cpp/zxing-core/core/src/datamatrix/DMDataBlock.h +41 -0
- package/cpp/zxing-core/core/src/datamatrix/DMDecoder.cpp +457 -0
- package/cpp/zxing-core/core/src/datamatrix/DMDecoder.h +19 -0
- package/cpp/zxing-core/core/src/datamatrix/DMDetector.cpp +1230 -0
- package/cpp/zxing-core/core/src/datamatrix/DMDetector.h +23 -0
- package/cpp/zxing-core/core/src/datamatrix/DMECEncoder.cpp +137 -0
- package/cpp/zxing-core/core/src/datamatrix/DMECEncoder.h +26 -0
- package/cpp/zxing-core/core/src/datamatrix/DMEncoderContext.h +128 -0
- package/cpp/zxing-core/core/src/datamatrix/DMHighLevelEncoder.cpp +919 -0
- package/cpp/zxing-core/core/src/datamatrix/DMHighLevelEncoder.h +29 -0
- package/cpp/zxing-core/core/src/datamatrix/DMReader.cpp +40 -0
- package/cpp/zxing-core/core/src/datamatrix/DMReader.h +21 -0
- package/cpp/zxing-core/core/src/datamatrix/DMSymbolInfo.cpp +141 -0
- package/cpp/zxing-core/core/src/datamatrix/DMSymbolInfo.h +78 -0
- package/cpp/zxing-core/core/src/datamatrix/DMSymbolShape.h +17 -0
- package/cpp/zxing-core/core/src/datamatrix/DMVersion.cpp +82 -0
- package/cpp/zxing-core/core/src/datamatrix/DMVersion.h +76 -0
- package/cpp/zxing-core/core/src/datamatrix/DMWriter.cpp +114 -0
- package/cpp/zxing-core/core/src/datamatrix/DMWriter.h +62 -0
- package/cpp/zxing-core/core/src/librscpp/README.md +65 -0
- package/cpp/zxing-core/core/src/librscpp/decode.h +258 -0
- package/cpp/zxing-core/core/src/librscpp/encode.h +124 -0
- package/cpp/zxing-core/core/src/librscpp/field.h +158 -0
- package/cpp/zxing-core/core/src/librscpp/poly.h +194 -0
- package/cpp/zxing-core/core/src/libzint/2of5inter.c +1 -0
- package/cpp/zxing-core/core/src/libzint/2of5inter_based.c +1 -0
- package/cpp/zxing-core/core/src/libzint/aztec.c +1 -0
- package/cpp/zxing-core/core/src/libzint/aztec.h +1 -0
- package/cpp/zxing-core/core/src/libzint/big5.h +1 -0
- package/cpp/zxing-core/core/src/libzint/codabar.c +1 -0
- package/cpp/zxing-core/core/src/libzint/code.c +1 -0
- package/cpp/zxing-core/core/src/libzint/code128.c +1 -0
- package/cpp/zxing-core/core/src/libzint/code128.h +1 -0
- package/cpp/zxing-core/core/src/libzint/common.c +1 -0
- package/cpp/zxing-core/core/src/libzint/common.h +1 -0
- package/cpp/zxing-core/core/src/libzint/dmatrix.c +1 -0
- package/cpp/zxing-core/core/src/libzint/dmatrix.h +1 -0
- package/cpp/zxing-core/core/src/libzint/dxfilmedge.c +1 -0
- package/cpp/zxing-core/core/src/libzint/eci.c +1 -0
- package/cpp/zxing-core/core/src/libzint/eci.h +1 -0
- package/cpp/zxing-core/core/src/libzint/eci_sb.h +1 -0
- package/cpp/zxing-core/core/src/libzint/filemem.c +1 -0
- package/cpp/zxing-core/core/src/libzint/filemem.h +1 -0
- package/cpp/zxing-core/core/src/libzint/fonts/normal_woff2.h +1 -0
- package/cpp/zxing-core/core/src/libzint/fonts/upcean_woff2.h +1 -0
- package/cpp/zxing-core/core/src/libzint/gb18030.h +1 -0
- package/cpp/zxing-core/core/src/libzint/gb2312.h +1 -0
- package/cpp/zxing-core/core/src/libzint/gbk.h +1 -0
- package/cpp/zxing-core/core/src/libzint/general_field.c +1 -0
- package/cpp/zxing-core/core/src/libzint/general_field.h +1 -0
- package/cpp/zxing-core/core/src/libzint/gs1.c +1 -0
- package/cpp/zxing-core/core/src/libzint/gs1.h +1 -0
- package/cpp/zxing-core/core/src/libzint/gs1_lint.h +1 -0
- package/cpp/zxing-core/core/src/libzint/iso3166.h +1 -0
- package/cpp/zxing-core/core/src/libzint/iso4217.h +1 -0
- package/cpp/zxing-core/core/src/libzint/ksx1001.h +1 -0
- package/cpp/zxing-core/core/src/libzint/large.c +1 -0
- package/cpp/zxing-core/core/src/libzint/large.h +1 -0
- package/cpp/zxing-core/core/src/libzint/library.c +1 -0
- package/cpp/zxing-core/core/src/libzint/maxicode.c +1 -0
- package/cpp/zxing-core/core/src/libzint/maxicode.h +1 -0
- package/cpp/zxing-core/core/src/libzint/medical.c +1 -0
- package/cpp/zxing-core/core/src/libzint/output.c +1 -0
- package/cpp/zxing-core/core/src/libzint/output.h +1 -0
- package/cpp/zxing-core/core/src/libzint/pdf417.c +1 -0
- package/cpp/zxing-core/core/src/libzint/pdf417.h +1 -0
- package/cpp/zxing-core/core/src/libzint/pdf417_tabs.h +1 -0
- package/cpp/zxing-core/core/src/libzint/qr.c +1 -0
- package/cpp/zxing-core/core/src/libzint/qr.h +1 -0
- package/cpp/zxing-core/core/src/libzint/raster.c +1 -0
- package/cpp/zxing-core/core/src/libzint/raster_font.h +1 -0
- package/cpp/zxing-core/core/src/libzint/reedsol.c +1 -0
- package/cpp/zxing-core/core/src/libzint/reedsol.h +1 -0
- package/cpp/zxing-core/core/src/libzint/reedsol_logs.h +1 -0
- package/cpp/zxing-core/core/src/libzint/rss.c +1 -0
- package/cpp/zxing-core/core/src/libzint/rss.h +1 -0
- package/cpp/zxing-core/core/src/libzint/sjis.h +1 -0
- package/cpp/zxing-core/core/src/libzint/stubs.c +137 -0
- package/cpp/zxing-core/core/src/libzint/svg.c +1 -0
- package/cpp/zxing-core/core/src/libzint/telepen.c +1 -0
- package/cpp/zxing-core/core/src/libzint/upcean.c +1 -0
- package/cpp/zxing-core/core/src/libzint/vector.c +1 -0
- package/cpp/zxing-core/core/src/libzint/zfiletypes.h +1 -0
- package/cpp/zxing-core/core/src/libzint/zint.h +1 -0
- package/cpp/zxing-core/core/src/libzint/zintconfig.h +1 -0
- package/cpp/zxing-core/core/src/libzueci/README.md +11 -0
- package/cpp/zxing-core/core/src/libzueci/zueci.c +1718 -0
- package/cpp/zxing-core/core/src/libzueci/zueci.h +179 -0
- package/cpp/zxing-core/core/src/libzueci/zueci_big5.h +3884 -0
- package/cpp/zxing-core/core/src/libzueci/zueci_common.h +31 -0
- package/cpp/zxing-core/core/src/libzueci/zueci_gb18030.h +264 -0
- package/cpp/zxing-core/core/src/libzueci/zueci_gb2312.h +2381 -0
- package/cpp/zxing-core/core/src/libzueci/zueci_gbk.h +4047 -0
- package/cpp/zxing-core/core/src/libzueci/zueci_ksx1001.h +2932 -0
- package/cpp/zxing-core/core/src/libzueci/zueci_sb.h +1112 -0
- package/cpp/zxing-core/core/src/libzueci/zueci_sjis.h +2286 -0
- package/cpp/zxing-core/core/src/maxicode/MCBitMatrixParser.cpp +68 -0
- package/cpp/zxing-core/core/src/maxicode/MCBitMatrixParser.h +30 -0
- package/cpp/zxing-core/core/src/maxicode/MCDecoder.cpp +329 -0
- package/cpp/zxing-core/core/src/maxicode/MCDecoder.h +19 -0
- package/cpp/zxing-core/core/src/maxicode/MCReader.cpp +65 -0
- package/cpp/zxing-core/core/src/maxicode/MCReader.h +21 -0
- package/cpp/zxing-core/core/src/oned/ODCodabarReader.cpp +102 -0
- package/cpp/zxing-core/core/src/oned/ODCodabarReader.h +21 -0
- package/cpp/zxing-core/core/src/oned/ODCodabarWriter.cpp +136 -0
- package/cpp/zxing-core/core/src/oned/ODCodabarWriter.h +34 -0
- package/cpp/zxing-core/core/src/oned/ODCode128Patterns.h +130 -0
- package/cpp/zxing-core/core/src/oned/ODCode128Reader.cpp +236 -0
- package/cpp/zxing-core/core/src/oned/ODCode128Reader.h +21 -0
- package/cpp/zxing-core/core/src/oned/ODCode128Writer.cpp +261 -0
- package/cpp/zxing-core/core/src/oned/ODCode128Writer.h +34 -0
- package/cpp/zxing-core/core/src/oned/ODCode39Reader.cpp +213 -0
- package/cpp/zxing-core/core/src/oned/ODCode39Reader.h +26 -0
- package/cpp/zxing-core/core/src/oned/ODCode39Writer.cpp +176 -0
- package/cpp/zxing-core/core/src/oned/ODCode39Writer.h +34 -0
- package/cpp/zxing-core/core/src/oned/ODCode93Patterns.h +80 -0
- package/cpp/zxing-core/core/src/oned/ODCode93Reader.cpp +112 -0
- package/cpp/zxing-core/core/src/oned/ODCode93Reader.h +21 -0
- package/cpp/zxing-core/core/src/oned/ODCode93Writer.cpp +192 -0
- package/cpp/zxing-core/core/src/oned/ODCode93Writer.h +32 -0
- package/cpp/zxing-core/core/src/oned/ODDXFilmEdgeReader.cpp +246 -0
- package/cpp/zxing-core/core/src/oned/ODDXFilmEdgeReader.h +26 -0
- package/cpp/zxing-core/core/src/oned/ODDataBarCommon.cpp +172 -0
- package/cpp/zxing-core/core/src/oned/ODDataBarCommon.h +204 -0
- package/cpp/zxing-core/core/src/oned/ODDataBarExpandedBitDecoder.cpp +253 -0
- package/cpp/zxing-core/core/src/oned/ODDataBarExpandedBitDecoder.h +19 -0
- package/cpp/zxing-core/core/src/oned/ODDataBarExpandedReader.cpp +383 -0
- package/cpp/zxing-core/core/src/oned/ODDataBarExpandedReader.h +25 -0
- package/cpp/zxing-core/core/src/oned/ODDataBarLimitedReader.cpp +163 -0
- package/cpp/zxing-core/core/src/oned/ODDataBarLimitedReader.h +23 -0
- package/cpp/zxing-core/core/src/oned/ODDataBarReader.cpp +240 -0
- package/cpp/zxing-core/core/src/oned/ODDataBarReader.h +25 -0
- package/cpp/zxing-core/core/src/oned/ODEAN13Writer.cpp +62 -0
- package/cpp/zxing-core/core/src/oned/ODEAN13Writer.h +34 -0
- package/cpp/zxing-core/core/src/oned/ODEAN8Writer.cpp +51 -0
- package/cpp/zxing-core/core/src/oned/ODEAN8Writer.h +34 -0
- package/cpp/zxing-core/core/src/oned/ODITFReader.cpp +97 -0
- package/cpp/zxing-core/core/src/oned/ODITFReader.h +33 -0
- package/cpp/zxing-core/core/src/oned/ODITFWriter.cpp +78 -0
- package/cpp/zxing-core/core/src/oned/ODITFWriter.h +34 -0
- package/cpp/zxing-core/core/src/oned/ODMultiUPCEANReader.cpp +323 -0
- package/cpp/zxing-core/core/src/oned/ODMultiUPCEANReader.h +32 -0
- package/cpp/zxing-core/core/src/oned/ODReader.cpp +259 -0
- package/cpp/zxing-core/core/src/oned/ODReader.h +35 -0
- package/cpp/zxing-core/core/src/oned/ODRowReader.h +222 -0
- package/cpp/zxing-core/core/src/oned/ODTelepenReader.cpp +199 -0
- package/cpp/zxing-core/core/src/oned/ODTelepenReader.h +25 -0
- package/cpp/zxing-core/core/src/oned/ODUPCAWriter.cpp +33 -0
- package/cpp/zxing-core/core/src/oned/ODUPCAWriter.h +34 -0
- package/cpp/zxing-core/core/src/oned/ODUPCEANCommon.cpp +80 -0
- package/cpp/zxing-core/core/src/oned/ODUPCEANCommon.h +129 -0
- package/cpp/zxing-core/core/src/oned/ODUPCEWriter.cpp +56 -0
- package/cpp/zxing-core/core/src/oned/ODUPCEWriter.h +34 -0
- package/cpp/zxing-core/core/src/oned/ODWriterHelper.cpp +39 -0
- package/cpp/zxing-core/core/src/oned/ODWriterHelper.h +48 -0
- package/cpp/zxing-core/core/src/pdf417/MicroPDFReader.cpp +796 -0
- package/cpp/zxing-core/core/src/pdf417/MicroPDFReader.h +23 -0
- package/cpp/zxing-core/core/src/pdf417/PDF417.cpp +85 -0
- package/cpp/zxing-core/core/src/pdf417/PDF417.h +81 -0
- package/cpp/zxing-core/core/src/pdf417/PDFBarcodeMetadata.h +53 -0
- package/cpp/zxing-core/core/src/pdf417/PDFBarcodeValue.cpp +48 -0
- package/cpp/zxing-core/core/src/pdf417/PDFBarcodeValue.h +38 -0
- package/cpp/zxing-core/core/src/pdf417/PDFBoundingBox.cpp +116 -0
- package/cpp/zxing-core/core/src/pdf417/PDFBoundingBox.h +75 -0
- package/cpp/zxing-core/core/src/pdf417/PDFCodeword.h +71 -0
- package/cpp/zxing-core/core/src/pdf417/PDFCodewordDecoder.cpp +588 -0
- package/cpp/zxing-core/core/src/pdf417/PDFCodewordDecoder.h +41 -0
- package/cpp/zxing-core/core/src/pdf417/PDFCompaction.h +20 -0
- package/cpp/zxing-core/core/src/pdf417/PDFCustomData.h +32 -0
- package/cpp/zxing-core/core/src/pdf417/PDFDecoder.cpp +725 -0
- package/cpp/zxing-core/core/src/pdf417/PDFDecoder.h +20 -0
- package/cpp/zxing-core/core/src/pdf417/PDFDetectionResult.cpp +247 -0
- package/cpp/zxing-core/core/src/pdf417/PDFDetectionResult.h +74 -0
- package/cpp/zxing-core/core/src/pdf417/PDFDetectionResultColumn.cpp +321 -0
- package/cpp/zxing-core/core/src/pdf417/PDFDetectionResultColumn.h +83 -0
- package/cpp/zxing-core/core/src/pdf417/PDFDetector.cpp +371 -0
- package/cpp/zxing-core/core/src/pdf417/PDFDetector.h +45 -0
- package/cpp/zxing-core/core/src/pdf417/PDFEncoder.cpp +570 -0
- package/cpp/zxing-core/core/src/pdf417/PDFEncoder.h +182 -0
- package/cpp/zxing-core/core/src/pdf417/PDFHighLevelEncoder.cpp +570 -0
- package/cpp/zxing-core/core/src/pdf417/PDFHighLevelEncoder.h +32 -0
- package/cpp/zxing-core/core/src/pdf417/PDFReader.cpp +333 -0
- package/cpp/zxing-core/core/src/pdf417/PDFReader.h +28 -0
- package/cpp/zxing-core/core/src/pdf417/PDFScanningDecoder.cpp +559 -0
- package/cpp/zxing-core/core/src/pdf417/PDFScanningDecoder.h +41 -0
- package/cpp/zxing-core/core/src/pdf417/PDFWriter.cpp +170 -0
- package/cpp/zxing-core/core/src/pdf417/PDFWriter.h +74 -0
- package/cpp/zxing-core/core/src/pdf417/ZXBigInteger.cpp +623 -0
- package/cpp/zxing-core/core/src/pdf417/ZXBigInteger.h +81 -0
- package/cpp/zxing-core/core/src/pdf417/ZXNullable.h +105 -0
- package/cpp/zxing-core/core/src/qrcode/QRBitMatrixParser.cpp +294 -0
- package/cpp/zxing-core/core/src/qrcode/QRBitMatrixParser.h +41 -0
- package/cpp/zxing-core/core/src/qrcode/QRCodecMode.cpp +95 -0
- package/cpp/zxing-core/core/src/qrcode/QRCodecMode.h +59 -0
- package/cpp/zxing-core/core/src/qrcode/QRDataBlock.cpp +93 -0
- package/cpp/zxing-core/core/src/qrcode/QRDataBlock.h +52 -0
- package/cpp/zxing-core/core/src/qrcode/QRDataMask.h +50 -0
- package/cpp/zxing-core/core/src/qrcode/QRDecoder.cpp +359 -0
- package/cpp/zxing-core/core/src/qrcode/QRDecoder.h +19 -0
- package/cpp/zxing-core/core/src/qrcode/QRDetector.cpp +920 -0
- package/cpp/zxing-core/core/src/qrcode/QRDetector.h +45 -0
- package/cpp/zxing-core/core/src/qrcode/QRECB.h +52 -0
- package/cpp/zxing-core/core/src/qrcode/QREncodeResult.h +33 -0
- package/cpp/zxing-core/core/src/qrcode/QREncoder.cpp +568 -0
- package/cpp/zxing-core/core/src/qrcode/QREncoder.h +21 -0
- package/cpp/zxing-core/core/src/qrcode/QRErrorCorrectionLevel.cpp +51 -0
- package/cpp/zxing-core/core/src/qrcode/QRErrorCorrectionLevel.h +39 -0
- package/cpp/zxing-core/core/src/qrcode/QRFormatInformation.cpp +160 -0
- package/cpp/zxing-core/core/src/qrcode/QRFormatInformation.h +61 -0
- package/cpp/zxing-core/core/src/qrcode/QRMaskUtil.cpp +156 -0
- package/cpp/zxing-core/core/src/qrcode/QRMaskUtil.h +15 -0
- package/cpp/zxing-core/core/src/qrcode/QRMatrixUtil.cpp +318 -0
- package/cpp/zxing-core/core/src/qrcode/QRMatrixUtil.h +25 -0
- package/cpp/zxing-core/core/src/qrcode/QRReader.cpp +149 -0
- package/cpp/zxing-core/core/src/qrcode/QRReader.h +21 -0
- package/cpp/zxing-core/core/src/qrcode/QRVersion.cpp +754 -0
- package/cpp/zxing-core/core/src/qrcode/QRVersion.h +127 -0
- package/cpp/zxing-core/core/src/qrcode/QRWriter.cpp +51 -0
- package/cpp/zxing-core/core/src/qrcode/QRWriter.h +74 -0
- package/cpp/zxing-core/core/version.rc.in +34 -0
- package/cpp/zxing-core/core/zxing.pc.in +8 -0
- package/cpp/zxing-core/wrappers/ios/README.md +25 -0
- package/cpp/zxing-core/wrappers/ios/Sources/Wrapper/Version.h +29 -0
- package/cpp/zxing-core/zxing-cpp.podspec +45 -0
- package/lib/factory.d.ts +10 -0
- package/lib/factory.js +12 -0
- package/lib/index.d.ts +9 -0
- package/lib/index.js +9 -0
- package/lib/specs/Barcode.nitro.d.ts +63 -0
- package/lib/specs/Barcode.nitro.js +1 -0
- package/lib/specs/BarcodeFormat.d.ts +11 -0
- package/lib/specs/BarcodeFormat.js +1 -0
- package/lib/specs/BarcodeScanner.nitro.d.ts +89 -0
- package/lib/specs/BarcodeScanner.nitro.js +1 -0
- package/lib/specs/BarcodeScannerFactory.nitro.d.ts +26 -0
- package/lib/specs/BarcodeScannerFactory.nitro.js +1 -0
- package/lib/specs/BarcodeValueType.d.ts +9 -0
- package/lib/specs/BarcodeValueType.js +1 -0
- package/lib/specs/Point.d.ts +14 -0
- package/lib/specs/Point.js +1 -0
- package/lib/specs/Rect.d.ts +22 -0
- package/lib/specs/Rect.js +1 -0
- package/lib/useBarcodeScanner.d.ts +23 -0
- package/lib/useBarcodeScanner.js +25 -0
- package/nitro.json +20 -0
- package/nitrogen/generated/.gitattributes +1 -0
- package/nitrogen/generated/android/VisionCameraZxing+autolinking.cmake +83 -0
- package/nitrogen/generated/android/VisionCameraZxing+autolinking.gradle +27 -0
- package/nitrogen/generated/android/VisionCameraZxingOnLoad.cpp +49 -0
- package/nitrogen/generated/android/VisionCameraZxingOnLoad.hpp +34 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/camera/zxing/VisionCameraZxingOnLoad.kt +35 -0
- package/nitrogen/generated/ios/VisionCameraZxing+autolinking.rb +62 -0
- package/nitrogen/generated/ios/VisionCameraZxing-Swift-Cxx-Bridge.cpp +17 -0
- package/nitrogen/generated/ios/VisionCameraZxing-Swift-Cxx-Bridge.hpp +27 -0
- package/nitrogen/generated/ios/VisionCameraZxing-Swift-Cxx-Umbrella.hpp +38 -0
- package/nitrogen/generated/ios/VisionCameraZxingAutolinking.mm +35 -0
- package/nitrogen/generated/ios/VisionCameraZxingAutolinking.swift +16 -0
- package/nitrogen/generated/shared/c++/BarcodeFormat.hpp +124 -0
- package/nitrogen/generated/shared/c++/BarcodeScannerOptions.hpp +85 -0
- package/nitrogen/generated/shared/c++/BarcodeValueType.hpp +120 -0
- package/nitrogen/generated/shared/c++/HybridBarcodeScannerSpec.cpp +23 -0
- package/nitrogen/generated/shared/c++/HybridBarcodeScannerSpec.hpp +74 -0
- package/nitrogen/generated/shared/c++/HybridBarcodeSpec.cpp +27 -0
- package/nitrogen/generated/shared/c++/HybridBarcodeSpec.hpp +82 -0
- package/nitrogen/generated/shared/c++/HybridZXingBarcodeScannerFactorySpec.cpp +21 -0
- package/nitrogen/generated/shared/c++/HybridZXingBarcodeScannerFactorySpec.hpp +67 -0
- package/nitrogen/generated/shared/c++/Point.hpp +87 -0
- package/nitrogen/generated/shared/c++/Rect.hpp +95 -0
- package/nitrogen/generated/shared/c++/TargetBarcodeFormat.hpp +124 -0
- package/package.json +108 -0
- package/react-native.config.js +16 -0
- package/src/factory.ts +26 -0
- package/src/index.ts +9 -0
- package/src/specs/Barcode.nitro.ts +70 -0
- package/src/specs/BarcodeFormat.ts +31 -0
- package/src/specs/BarcodeScanner.nitro.ts +91 -0
- package/src/specs/BarcodeScannerFactory.nitro.ts +27 -0
- package/src/specs/BarcodeValueType.ts +25 -0
- package/src/specs/Point.ts +14 -0
- package/src/specs/Rect.ts +22 -0
- package/src/useBarcodeScanner.ts +36 -0
|
@@ -0,0 +1,457 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2016 Nu-book Inc.
|
|
3
|
+
* Copyright 2016 ZXing authors
|
|
4
|
+
*/
|
|
5
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
6
|
+
|
|
7
|
+
#include "DMDecoder.h"
|
|
8
|
+
|
|
9
|
+
#include "Barcode.h"
|
|
10
|
+
#include "BitMatrix.h"
|
|
11
|
+
#include "BitSource.h"
|
|
12
|
+
#include "ByteArray.h"
|
|
13
|
+
#include "DMBitLayout.h"
|
|
14
|
+
#include "DMDataBlock.h"
|
|
15
|
+
#include "DMVersion.h"
|
|
16
|
+
#include "DecoderResult.h"
|
|
17
|
+
#include "ReedSolomon.h"
|
|
18
|
+
#include "ZXAlgorithms.h"
|
|
19
|
+
#include "ZXTestSupport.h"
|
|
20
|
+
|
|
21
|
+
#include <algorithm>
|
|
22
|
+
#include <array>
|
|
23
|
+
#include <optional>
|
|
24
|
+
#include <string>
|
|
25
|
+
#include <utility>
|
|
26
|
+
#include <vector>
|
|
27
|
+
|
|
28
|
+
namespace ZXing::DataMatrix {
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* <p>Data Matrix Codes can encode text as bits in one of several modes, and can use multiple modes
|
|
32
|
+
* in one Data Matrix Code. This class decodes the bits back into text.</p>
|
|
33
|
+
*
|
|
34
|
+
* <p>See ISO 16022:2006, 5.2.1 - 5.2.9.2</p>
|
|
35
|
+
*
|
|
36
|
+
* @author bbrown@google.com (Brian Brown)
|
|
37
|
+
* @author Sean Owen
|
|
38
|
+
*/
|
|
39
|
+
namespace DecodedBitStreamParser {
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* See ISO 16022:2006, Annex C Table C.1
|
|
43
|
+
* The C40 Basic Character Set (*'s used for placeholders for the shift values)
|
|
44
|
+
*/
|
|
45
|
+
static constexpr std::array C40_BASIC_SET_CHARS = {
|
|
46
|
+
'*', '*', '*', ' ', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
|
|
47
|
+
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N',
|
|
48
|
+
'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
static constexpr std::array C40_SHIFT2_SET_CHARS = {
|
|
52
|
+
'!', '"', '#', '$', '%', '&', '\'', '(', ')', '*', '+', ',', '-', '.',
|
|
53
|
+
'/', ':', ';', '<', '=', '>', '?', '@', '[', '\\', ']', '^', '_', (char)29 // FNC1->29
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* See ISO 16022:2006, Annex C Table C.2
|
|
58
|
+
* The Text Basic Character Set (*'s used for placeholders for the shift values)
|
|
59
|
+
*/
|
|
60
|
+
static constexpr std::array TEXT_BASIC_SET_CHARS = {
|
|
61
|
+
'*', '*', '*', ' ', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
|
|
62
|
+
'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n',
|
|
63
|
+
'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
// Shift 2 for Text is the same encoding as C40
|
|
67
|
+
#define TEXT_SHIFT2_SET_CHARS C40_SHIFT2_SET_CHARS
|
|
68
|
+
|
|
69
|
+
static constexpr std::array TEXT_SHIFT3_SET_CHARS = {
|
|
70
|
+
'`', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N',
|
|
71
|
+
'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '{', '|', '}', '~', (char)127
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
struct Shift128
|
|
75
|
+
{
|
|
76
|
+
bool set = false;
|
|
77
|
+
char operator()(int val) { return static_cast<char>(val + std::exchange(set, false) * 128); }
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* See ISO 16022:2006, 5.4.1, Table 6
|
|
82
|
+
*/
|
|
83
|
+
static ECI ParseECIValue(BitSource& bits)
|
|
84
|
+
{
|
|
85
|
+
int firstByte = bits.readBits(8);
|
|
86
|
+
if (firstByte <= 127)
|
|
87
|
+
return ECI(firstByte - 1);
|
|
88
|
+
|
|
89
|
+
int secondByte = bits.readBits(8);
|
|
90
|
+
if (firstByte <= 191)
|
|
91
|
+
return ECI((firstByte - 128) * 254 + 127 + secondByte - 1);
|
|
92
|
+
|
|
93
|
+
int thirdByte = bits.readBits(8);
|
|
94
|
+
|
|
95
|
+
return ECI((firstByte - 192) * 64516 + 16383 + (secondByte - 1) * 254 + thirdByte - 1);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* See ISO 16022:2006, 5.6
|
|
100
|
+
*/
|
|
101
|
+
static void ParseStructuredAppend(BitSource& bits, StructuredAppendInfo& sai)
|
|
102
|
+
{
|
|
103
|
+
// 5.6.2 Table 8
|
|
104
|
+
int symbolSequenceIndicator = bits.readBits(8);
|
|
105
|
+
sai.index = symbolSequenceIndicator >> 4;
|
|
106
|
+
sai.count = 17 - (symbolSequenceIndicator & 0x0F); // 2-16 permitted, 17 invalid
|
|
107
|
+
|
|
108
|
+
if (sai.count == 17 || sai.count <= sai.index) // If info doesn't make sense
|
|
109
|
+
sai.count = 0; // Choose to mark count as unknown
|
|
110
|
+
|
|
111
|
+
int fileId1 = bits.readBits(8); // File identification 1
|
|
112
|
+
int fileId2 = bits.readBits(8); // File identification 2
|
|
113
|
+
|
|
114
|
+
// There's no conversion method or meaning given to the 2 file id codewords in Section 5.6.3, apart from
|
|
115
|
+
// saying that each value should be 1-254. Choosing here to represent them as base 256.
|
|
116
|
+
sai.id = std::to_string((fileId1 << 8) | fileId2);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
std::optional<std::array<int, 3>> DecodeNextTriple(BitSource& bits)
|
|
120
|
+
{
|
|
121
|
+
// Values are encoded in a 16-bit value as (1600 * C1) + (40 * C2) + C3 + 1
|
|
122
|
+
// If there is less than 2 bytes left or the next byte is the unlatch codeword then the current segment has ended
|
|
123
|
+
if (bits.available() < 16)
|
|
124
|
+
return {};
|
|
125
|
+
int firstByte = bits.readBits(8);
|
|
126
|
+
if (firstByte == 254) // Unlatch codeword
|
|
127
|
+
return {};
|
|
128
|
+
|
|
129
|
+
int fullBitValue = (firstByte << 8) + bits.readBits(8) - 1;
|
|
130
|
+
int a = fullBitValue / 1600;
|
|
131
|
+
fullBitValue -= a * 1600;
|
|
132
|
+
int b = fullBitValue / 40;
|
|
133
|
+
int c = fullBitValue - b * 40;
|
|
134
|
+
|
|
135
|
+
return {{a, b, c}};
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
enum class Mode {C40, TEXT};
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* See ISO 16022:2006, 5.2.5 and Annex C, Table C.1 (C40)
|
|
142
|
+
* See ISO 16022:2006, 5.2.6 and Annex C, Table C.2 (Text)
|
|
143
|
+
*/
|
|
144
|
+
static void DecodeC40OrTextSegment(BitSource& bits, Content& result, Mode mode)
|
|
145
|
+
{
|
|
146
|
+
// TODO(bbrown): The Upper Shift with C40 doesn't work in the 4 value scenario all the time
|
|
147
|
+
Shift128 upperShift;
|
|
148
|
+
int shift = 0;
|
|
149
|
+
|
|
150
|
+
auto& BASIC_SET_CHARS = mode == Mode::C40 ? C40_BASIC_SET_CHARS : TEXT_BASIC_SET_CHARS;
|
|
151
|
+
auto& SHIFT_SET_CHARS = mode == Mode::C40 ? C40_SHIFT2_SET_CHARS : TEXT_SHIFT2_SET_CHARS;
|
|
152
|
+
|
|
153
|
+
while (auto triple = DecodeNextTriple(bits)) {
|
|
154
|
+
for (int cValue : *triple) {
|
|
155
|
+
switch (std::exchange(shift, 0)) {
|
|
156
|
+
case 0:
|
|
157
|
+
if (cValue < 3)
|
|
158
|
+
shift = cValue + 1;
|
|
159
|
+
else if (cValue < Size(BASIC_SET_CHARS))
|
|
160
|
+
result.push_back(upperShift(BASIC_SET_CHARS[cValue]));
|
|
161
|
+
else
|
|
162
|
+
throw FormatError("invalid value in C40 or Text segment");
|
|
163
|
+
break;
|
|
164
|
+
case 1: result.push_back(upperShift(cValue)); break;
|
|
165
|
+
case 2:
|
|
166
|
+
if (cValue < Size(SHIFT_SET_CHARS))
|
|
167
|
+
result.push_back(upperShift(SHIFT_SET_CHARS[cValue]));
|
|
168
|
+
else if (cValue == 30) // Upper Shift
|
|
169
|
+
upperShift.set = true;
|
|
170
|
+
else
|
|
171
|
+
throw FormatError("invalid value in C40 or Text segment");
|
|
172
|
+
break;
|
|
173
|
+
case 3:
|
|
174
|
+
if (mode == Mode::C40)
|
|
175
|
+
result.push_back(upperShift(cValue + 96));
|
|
176
|
+
else if (cValue < Size(TEXT_SHIFT3_SET_CHARS))
|
|
177
|
+
result.push_back(upperShift(TEXT_SHIFT3_SET_CHARS[cValue]));
|
|
178
|
+
else
|
|
179
|
+
throw FormatError("invalid value in C40 or Text segment");
|
|
180
|
+
break;
|
|
181
|
+
default: throw FormatError("invalid value in C40 or Text segment"); ;
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
/**
|
|
188
|
+
* See ISO 16022:2006, 5.2.7
|
|
189
|
+
*/
|
|
190
|
+
static void DecodeAnsiX12Segment(BitSource& bits, Content& result)
|
|
191
|
+
{
|
|
192
|
+
while (auto triple = DecodeNextTriple(bits)) {
|
|
193
|
+
for (int cValue : *triple) {
|
|
194
|
+
// X12 segment terminator <CR>, separator *, sub-element separator >, space
|
|
195
|
+
static const char segChars[4] = {'\r', '*', '>', ' '};
|
|
196
|
+
if (cValue < 0)
|
|
197
|
+
throw FormatError("invalid value in AnsiX12 segment");
|
|
198
|
+
else if (cValue < 4)
|
|
199
|
+
result.push_back(segChars[cValue]);
|
|
200
|
+
else if (cValue < 14) // 0 - 9
|
|
201
|
+
result.push_back((char)(cValue + 44));
|
|
202
|
+
else if (cValue < 40) // A - Z
|
|
203
|
+
result.push_back((char)(cValue + 51));
|
|
204
|
+
else
|
|
205
|
+
throw FormatError("invalid value in AnsiX12 segment");
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
/**
|
|
211
|
+
* See ISO 16022:2006, 5.2.8 and Annex C Table C.3
|
|
212
|
+
*/
|
|
213
|
+
static void DecodeEdifactSegment(BitSource& bits, Content& result)
|
|
214
|
+
{
|
|
215
|
+
// If there are less than 3 bytes left then it will be encoded as ASCII
|
|
216
|
+
while (bits.available() >= 24) {
|
|
217
|
+
for (int i = 0; i < 4; i++) {
|
|
218
|
+
char edifactValue = bits.readBits(6);
|
|
219
|
+
|
|
220
|
+
// Check for the unlatch character
|
|
221
|
+
if (edifactValue == 0x1F) { // 011111
|
|
222
|
+
// Read rest of byte, which should be 0, and stop
|
|
223
|
+
if (bits.bitOffset())
|
|
224
|
+
bits.readBits(8 - bits.bitOffset());
|
|
225
|
+
return;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
if ((edifactValue & 0x20) == 0) // no 1 in the leading (6th) bit
|
|
229
|
+
edifactValue |= 0x40; // Add a leading 01 to the 6 bit binary value
|
|
230
|
+
result.push_back(edifactValue);
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
/**
|
|
236
|
+
* See ISO 16022:2006, Annex B, B.2
|
|
237
|
+
*/
|
|
238
|
+
static int Unrandomize255State(int randomizedBase256Codeword, int base256CodewordPosition)
|
|
239
|
+
{
|
|
240
|
+
int pseudoRandomNumber = ((149 * base256CodewordPosition) % 255) + 1;
|
|
241
|
+
int tempVariable = randomizedBase256Codeword - pseudoRandomNumber;
|
|
242
|
+
return tempVariable >= 0 ? tempVariable : tempVariable + 256;
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
/**
|
|
246
|
+
* See ISO 16022:2006, 5.2.9 and Annex B, B.2
|
|
247
|
+
*/
|
|
248
|
+
static void DecodeBase256Segment(BitSource& bits, Content& result)
|
|
249
|
+
{
|
|
250
|
+
// Figure out how long the Base 256 Segment is.
|
|
251
|
+
int codewordPosition = 1 + bits.byteOffset(); // position is 1-indexed
|
|
252
|
+
int d1 = Unrandomize255State(bits.readBits(8), codewordPosition++);
|
|
253
|
+
int count;
|
|
254
|
+
if (d1 == 0) // Read the remainder of the symbol
|
|
255
|
+
count = bits.available() / 8;
|
|
256
|
+
else if (d1 < 250)
|
|
257
|
+
count = d1;
|
|
258
|
+
else
|
|
259
|
+
count = 250 * (d1 - 249) + Unrandomize255State(bits.readBits(8), codewordPosition++);
|
|
260
|
+
|
|
261
|
+
// We're seeing NegativeArraySizeException errors from users.
|
|
262
|
+
if (count < 0)
|
|
263
|
+
throw FormatError("invalid count in Base256 segment");
|
|
264
|
+
|
|
265
|
+
result.reserve(count);
|
|
266
|
+
for (int i = 0; i < count; i++) {
|
|
267
|
+
// readBits(8) may fail, have seen this particular error in the wild, such as at
|
|
268
|
+
// http://www.bcgen.com/demo/IDAutomationStreamingDataMatrix.aspx?MODE=3&D=Fred&PFMT=3&PT=F&X=0.3&O=0&LM=0.2
|
|
269
|
+
result.push_back(Unrandomize255State(bits.readBits(8), codewordPosition++));
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
ZXING_EXPORT_TEST_ONLY
|
|
274
|
+
DecoderResult Decode(ByteArray&& bytes, const bool isDMRE)
|
|
275
|
+
{
|
|
276
|
+
BitSource bits(bytes);
|
|
277
|
+
Content result;
|
|
278
|
+
Error error;
|
|
279
|
+
result.symbology = {'d', '1', 3}; // ECC 200 (ISO 16022:2006 Annex N Table N.1)
|
|
280
|
+
std::string resultTrailer;
|
|
281
|
+
|
|
282
|
+
struct StructuredAppendInfo sai;
|
|
283
|
+
bool readerInit = false;
|
|
284
|
+
bool firstCodeword = true;
|
|
285
|
+
bool done = false;
|
|
286
|
+
int firstFNC1Position = 1;
|
|
287
|
+
Shift128 upperShift;
|
|
288
|
+
|
|
289
|
+
auto setError = [&error](Error&& e) {
|
|
290
|
+
// return only the first error but keep on decoding if possible
|
|
291
|
+
if (!error)
|
|
292
|
+
error = std::move(e);
|
|
293
|
+
};
|
|
294
|
+
|
|
295
|
+
// See ISO 16022:2006, 5.2.3 and Annex C, Table C.2
|
|
296
|
+
try {
|
|
297
|
+
while (!done && bits.available() >= 8) {
|
|
298
|
+
int oneByte = bits.readBits(8);
|
|
299
|
+
switch (oneByte) {
|
|
300
|
+
case 0: setError(FormatError("invalid 0 code word")); break;
|
|
301
|
+
case 129: done = true; break; // Pad -> we are done, ignore the rest of the bits
|
|
302
|
+
case 230: DecodeC40OrTextSegment(bits, result, Mode::C40); break;
|
|
303
|
+
case 231: DecodeBase256Segment(bits, result); break;
|
|
304
|
+
case 232: // FNC1
|
|
305
|
+
// Only recognizing an FNC1 as first/second by codeword position (aka symbol character position), not
|
|
306
|
+
// by decoded character position, i.e. not recognizing a C40/Text encoded FNC1 (which requires a latch
|
|
307
|
+
// and a shift)
|
|
308
|
+
if (bits.byteOffset() == firstFNC1Position)
|
|
309
|
+
result.symbology.modifier = '2'; // GS1
|
|
310
|
+
// 2nd position AIM, note no AIM Application Indicator format defined in ISO/IEC 16022:2006 11.2
|
|
311
|
+
// however FNC1-originator Code 128 restricts ids to A-Z, a-z, 00-99 so enforcing that here
|
|
312
|
+
else if (bits.byteOffset() == firstFNC1Position + 1
|
|
313
|
+
&& ((Size(result.bytes) == 1 && IsAlpha(result.bytes[0]))
|
|
314
|
+
|| (Size(result.bytes) == 2 && IsDigit(result.bytes[0]) && IsDigit(result.bytes[1]))))
|
|
315
|
+
result.symbology.modifier = '3';
|
|
316
|
+
else
|
|
317
|
+
result.push_back((char)29); // translate as ASCII 29 <GS>
|
|
318
|
+
break;
|
|
319
|
+
case 233: // Structured Append
|
|
320
|
+
if (!firstCodeword) // Must be first ISO 16022:2006 5.6.1
|
|
321
|
+
setError(FormatError("structured append tag must be first code word"));
|
|
322
|
+
ParseStructuredAppend(bits, sai);
|
|
323
|
+
firstFNC1Position = 5;
|
|
324
|
+
break;
|
|
325
|
+
case 234: // Reader Programming
|
|
326
|
+
if (!firstCodeword) // Must be first ISO 16022:2006 5.2.4.9
|
|
327
|
+
setError(FormatError("reader programming tag must be first code word"));
|
|
328
|
+
readerInit = true;
|
|
329
|
+
break;
|
|
330
|
+
case 235: upperShift.set = true; break; // Upper Shift (shift to Extended ASCII)
|
|
331
|
+
case 236: // ISO 15434 format "05" Macro
|
|
332
|
+
result.append("[)>\x1E" "05\x1D");
|
|
333
|
+
resultTrailer.insert(0, "\x1E\x04");
|
|
334
|
+
break;
|
|
335
|
+
case 237: // ISO 15434 format "06" Macro
|
|
336
|
+
result.append("[)>\x1E" "06\x1D");
|
|
337
|
+
resultTrailer.insert(0, "\x1E\x04");
|
|
338
|
+
break;
|
|
339
|
+
case 238: DecodeAnsiX12Segment(bits, result); break;
|
|
340
|
+
case 239: DecodeC40OrTextSegment(bits, result, Mode::TEXT); break;
|
|
341
|
+
case 240: DecodeEdifactSegment(bits, result); break;
|
|
342
|
+
case 241: result.switchEncoding(ParseECIValue(bits)); break;
|
|
343
|
+
default:
|
|
344
|
+
if (oneByte <= 128) { // ASCII data (ASCII value + 1)
|
|
345
|
+
result.push_back(upperShift(oneByte) - 1);
|
|
346
|
+
} else if (oneByte <= 229) { // 2-digit data 00-99 (Numeric Value + 130)
|
|
347
|
+
result.append(ToString(oneByte - 130, 2));
|
|
348
|
+
} else if (oneByte >= 242) { // Not to be used in ASCII encodation
|
|
349
|
+
// work around encoders that use unlatch to ASCII as last code word (ask upstream)
|
|
350
|
+
if (oneByte == 254 && bits.available() == 0)
|
|
351
|
+
break;
|
|
352
|
+
setError(FormatError("invalid code word"));
|
|
353
|
+
break;
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
firstCodeword = false;
|
|
357
|
+
}
|
|
358
|
+
} catch (Error e) {
|
|
359
|
+
setError(std::move(e));
|
|
360
|
+
} catch (std::out_of_range&) { // see BitSource::readBits
|
|
361
|
+
error = FormatError("Truncated bit stream");
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
result.append(resultTrailer);
|
|
365
|
+
result.symbology.aiFlag = result.symbology.modifier == '2' ? AIFlag::GS1 : AIFlag::None;
|
|
366
|
+
result.symbology.modifier += isDMRE * 6;
|
|
367
|
+
|
|
368
|
+
return DecoderResult(std::move(result))
|
|
369
|
+
.setError(std::move(error))
|
|
370
|
+
.setStructuredAppend(sai)
|
|
371
|
+
.setReaderInit(readerInit);
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
} // namespace DecodedBitStreamParser
|
|
375
|
+
|
|
376
|
+
|
|
377
|
+
static DecoderResult DoDecode(const BitMatrix& bits)
|
|
378
|
+
{
|
|
379
|
+
// Construct a parser and read version, error-correction level
|
|
380
|
+
const Version* version = VersionForDimensionsOf(bits);
|
|
381
|
+
if (version == nullptr)
|
|
382
|
+
return FormatError("Invalid matrix dimension");
|
|
383
|
+
|
|
384
|
+
// Read codewords
|
|
385
|
+
ByteArray codewords = CodewordsFromBitMatrix(bits, *version);
|
|
386
|
+
if (codewords.empty())
|
|
387
|
+
return FormatError("Invalid number of code words");
|
|
388
|
+
|
|
389
|
+
bool fix259 = false; // see https://github.com/zxing-cpp/zxing-cpp/issues/259
|
|
390
|
+
retry:
|
|
391
|
+
// Separate into data blocks
|
|
392
|
+
std::vector<DataBlock> dataBlocks = GetDataBlocks(codewords, *version, fix259);
|
|
393
|
+
if (dataBlocks.empty())
|
|
394
|
+
return FormatError("Invalid number of data blocks");
|
|
395
|
+
double uec = 1.0;
|
|
396
|
+
|
|
397
|
+
// Count total number of data bytes
|
|
398
|
+
ByteArray resultBytes(TransformReduce(dataBlocks, 0, [](const auto& db) { return db.numDataCodewords; }));
|
|
399
|
+
|
|
400
|
+
// Error-correct and copy data blocks together into a stream of bytes
|
|
401
|
+
const int dataBlocksCount = Size(dataBlocks);
|
|
402
|
+
for (int j = 0; j < dataBlocksCount; j++) {
|
|
403
|
+
auto& [numDataCodewords, codewords] = dataBlocks[j];
|
|
404
|
+
auto blockUEC = ReedSolomonDecode(RSField::DataMatrix, codewords, Size(codewords) - numDataCodewords);
|
|
405
|
+
if (!blockUEC) {
|
|
406
|
+
if(version->versionNumber == 24 && !fix259) {
|
|
407
|
+
fix259 = true;
|
|
408
|
+
goto retry;
|
|
409
|
+
}
|
|
410
|
+
return ChecksumError();
|
|
411
|
+
}
|
|
412
|
+
uec = std::min(uec, *blockUEC);
|
|
413
|
+
|
|
414
|
+
for (int i = 0; i < numDataCodewords; i++) {
|
|
415
|
+
// De-interlace data blocks.
|
|
416
|
+
resultBytes[i * dataBlocksCount + j] = codewords[i];
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
#ifdef PRINT_DEBUG
|
|
420
|
+
if (fix259)
|
|
421
|
+
printf("-> needed retry with fix259 for 144x144 symbol\n");
|
|
422
|
+
#endif
|
|
423
|
+
|
|
424
|
+
// Decode the contents of that stream of bytes
|
|
425
|
+
return DecodedBitStreamParser::Decode(std::move(resultBytes), version->isDMRE())
|
|
426
|
+
.setVersionNumber(version->versionNumber)
|
|
427
|
+
.addExtra(BarcodeExtra::UEC, uec, -1.0)
|
|
428
|
+
.addExtra(BarcodeExtra::Version, std::to_string(version->symbolHeight) + 'x' + std::to_string(version->symbolWidth));
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
static BitMatrix FlippedL(const BitMatrix& bits)
|
|
432
|
+
{
|
|
433
|
+
BitMatrix res(bits.height(), bits.width());
|
|
434
|
+
for (int y = 0; y < res.height(); ++y)
|
|
435
|
+
for (int x = 0; x < res.width(); ++x)
|
|
436
|
+
res.set(x, y, bits.get(bits.width() - 1 - y, bits.height() - 1 - x));
|
|
437
|
+
return res;
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
DecoderResult Decode(const BitMatrix& bits)
|
|
441
|
+
{
|
|
442
|
+
auto res = DoDecode(bits);
|
|
443
|
+
if (res.isValid())
|
|
444
|
+
return res;
|
|
445
|
+
|
|
446
|
+
//TODO:
|
|
447
|
+
// * unify bit mirroring helper code with QRReader?
|
|
448
|
+
// * rectangular symbols with the a size of 8 x Y are not supported a.t.m.
|
|
449
|
+
if (auto mirroredRes = DoDecode(FlippedL(bits)); mirroredRes.error().type() != Error::Checksum) {
|
|
450
|
+
mirroredRes.setIsMirrored(true);
|
|
451
|
+
return mirroredRes;
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
return res;
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
} // namespace ZXing::DataMatrix
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2016 Nu-book Inc.
|
|
3
|
+
* Copyright 2016 ZXing authors
|
|
4
|
+
*/
|
|
5
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
6
|
+
|
|
7
|
+
#pragma once
|
|
8
|
+
|
|
9
|
+
namespace ZXing {
|
|
10
|
+
|
|
11
|
+
class DecoderResult;
|
|
12
|
+
class BitMatrix;
|
|
13
|
+
|
|
14
|
+
namespace DataMatrix {
|
|
15
|
+
|
|
16
|
+
DecoderResult Decode(const BitMatrix& bits);
|
|
17
|
+
|
|
18
|
+
} // DataMatrix
|
|
19
|
+
} // ZXing
|