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,725 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2016 Nu-book Inc.
|
|
3
|
+
* Copyright 2016 ZXing authors
|
|
4
|
+
*/
|
|
5
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
6
|
+
|
|
7
|
+
#include "PDFDecoder.h"
|
|
8
|
+
|
|
9
|
+
#include "CharacterSet.h"
|
|
10
|
+
#include "DecoderResult.h"
|
|
11
|
+
#include "PDFCustomData.h"
|
|
12
|
+
#include "ZXAlgorithms.h"
|
|
13
|
+
#include "ZXBigInteger.h"
|
|
14
|
+
#include "ZXTestSupport.h"
|
|
15
|
+
|
|
16
|
+
#include <array>
|
|
17
|
+
#include <cassert>
|
|
18
|
+
#include <charconv>
|
|
19
|
+
#include <sstream>
|
|
20
|
+
#include <utility>
|
|
21
|
+
|
|
22
|
+
namespace ZXing::Pdf417 {
|
|
23
|
+
|
|
24
|
+
enum class Mode
|
|
25
|
+
{
|
|
26
|
+
ALPHA,
|
|
27
|
+
LOWER,
|
|
28
|
+
MIXED,
|
|
29
|
+
PUNCT,
|
|
30
|
+
ALPHA_SHIFT,
|
|
31
|
+
PUNCT_SHIFT
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
constexpr int TEXT_COMPACTION_MODE_LATCH = 900;
|
|
35
|
+
constexpr int BYTE_COMPACTION_MODE_LATCH = 901;
|
|
36
|
+
constexpr int NUMERIC_COMPACTION_MODE_LATCH = 902;
|
|
37
|
+
// 903-912 reserved
|
|
38
|
+
constexpr int MODE_SHIFT_TO_BYTE_COMPACTION_MODE = 913;
|
|
39
|
+
// 914-917 reserved
|
|
40
|
+
constexpr int LINKAGE_OTHER = 918;
|
|
41
|
+
// 919 reserved
|
|
42
|
+
constexpr int LINKAGE_EANUCC = 920; // GS1 Composite
|
|
43
|
+
constexpr int READER_INIT = 921; // Reader Initialisation/Programming
|
|
44
|
+
constexpr int MACRO_PDF417_TERMINATOR = 922;
|
|
45
|
+
constexpr int BEGIN_MACRO_PDF417_OPTIONAL_FIELD = 923;
|
|
46
|
+
constexpr int BYTE_COMPACTION_MODE_LATCH_6 = 924;
|
|
47
|
+
constexpr int ECI_USER_DEFINED = 925; // 810900-811799 (1 codeword)
|
|
48
|
+
constexpr int ECI_GENERAL_PURPOSE = 926; // 900-810899 (2 codewords)
|
|
49
|
+
constexpr int ECI_CHARSET = 927; // 0-899 (1 codeword)
|
|
50
|
+
constexpr int BEGIN_MACRO_PDF417_CONTROL_BLOCK = 928;
|
|
51
|
+
|
|
52
|
+
constexpr int MAX_NUMERIC_CODEWORDS = 15;
|
|
53
|
+
|
|
54
|
+
constexpr int MACRO_PDF417_OPTIONAL_FIELD_FILE_NAME = 0;
|
|
55
|
+
constexpr int MACRO_PDF417_OPTIONAL_FIELD_SEGMENT_COUNT = 1;
|
|
56
|
+
constexpr int MACRO_PDF417_OPTIONAL_FIELD_TIME_STAMP = 2;
|
|
57
|
+
constexpr int MACRO_PDF417_OPTIONAL_FIELD_SENDER = 3;
|
|
58
|
+
constexpr int MACRO_PDF417_OPTIONAL_FIELD_ADDRESSEE = 4;
|
|
59
|
+
constexpr int MACRO_PDF417_OPTIONAL_FIELD_FILE_SIZE = 5;
|
|
60
|
+
constexpr int MACRO_PDF417_OPTIONAL_FIELD_CHECKSUM = 6;
|
|
61
|
+
|
|
62
|
+
static const char* PUNCT_CHARS = ";<>@[\\]_`~!\r\t,:\n-.$/\"|*()?{}'";
|
|
63
|
+
static const char* MIXED_CHARS = "0123456789&\r\t,:#-.$/+%*=^";
|
|
64
|
+
|
|
65
|
+
constexpr int NUMBER_OF_SEQUENCE_CODEWORDS = 2;
|
|
66
|
+
|
|
67
|
+
inline bool IsECI(int code)
|
|
68
|
+
{
|
|
69
|
+
return code >= ECI_USER_DEFINED && code <= ECI_CHARSET;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Whether a codeword terminates a Compaction mode.
|
|
74
|
+
*
|
|
75
|
+
* See ISO/IEC 15438:2015 5.4.2.5 (Text), 5.4.3.4 (Byte), 5.4.4.3 (Numeric)
|
|
76
|
+
*/
|
|
77
|
+
static bool TerminatesCompaction(int code)
|
|
78
|
+
{
|
|
79
|
+
switch (code) {
|
|
80
|
+
case TEXT_COMPACTION_MODE_LATCH:
|
|
81
|
+
case BYTE_COMPACTION_MODE_LATCH:
|
|
82
|
+
case NUMERIC_COMPACTION_MODE_LATCH:
|
|
83
|
+
case BYTE_COMPACTION_MODE_LATCH_6:
|
|
84
|
+
case BEGIN_MACRO_PDF417_CONTROL_BLOCK:
|
|
85
|
+
case BEGIN_MACRO_PDF417_OPTIONAL_FIELD:
|
|
86
|
+
case MACRO_PDF417_TERMINATOR: return true;
|
|
87
|
+
}
|
|
88
|
+
return false;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Helper to process ECIs.
|
|
93
|
+
**/
|
|
94
|
+
static int ProcessECI(const std::vector<int>& codewords, int codeIndex, const int length, const int code, Content& result)
|
|
95
|
+
{
|
|
96
|
+
if (!IsECI(code))
|
|
97
|
+
return codeIndex;
|
|
98
|
+
|
|
99
|
+
if (codeIndex >= length)
|
|
100
|
+
return codeIndex; // throw FormatError(); TODO: check why there are unit tests that expect this to be silently ignored
|
|
101
|
+
|
|
102
|
+
if (code == ECI_CHARSET) {
|
|
103
|
+
result.switchEncoding(ECI(codewords[codeIndex++]));
|
|
104
|
+
} else {
|
|
105
|
+
int paramCount = code == ECI_GENERAL_PURPOSE ? 2 : 1;
|
|
106
|
+
if (codeIndex + paramCount > length)
|
|
107
|
+
return codeIndex; // throw FormatError(); TODO: check why there are unit tests that expect this to be silently ignored
|
|
108
|
+
codeIndex += paramCount; // Don't currently handle non-character set ECIs so just ignore
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
return codeIndex;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* The Text Compaction mode includes all the printable ASCII characters
|
|
116
|
+
* (i.e. values from 32 to 126) and three ASCII control characters: HT or tab
|
|
117
|
+
* (ASCII value 9), LF or line feed (ASCII value 10), and CR or carriage
|
|
118
|
+
* return (ASCII value 13). The Text Compaction mode also includes various latch
|
|
119
|
+
* and shift characters which are used exclusively within the mode. The Text
|
|
120
|
+
* Compaction mode encodes up to 2 characters per codeword. The compaction rules
|
|
121
|
+
* for converting data into PDF417 codewords are defined in 5.4.2.2. The sub-mode
|
|
122
|
+
* switches are defined in 5.4.2.3.
|
|
123
|
+
*
|
|
124
|
+
* @param textCompactionData The text compaction data.
|
|
125
|
+
* @param length The size of the text compaction data.
|
|
126
|
+
* @param result The data in the character set encoding.
|
|
127
|
+
*/
|
|
128
|
+
static void DecodeTextCompaction(const std::vector<int>& textCompactionData, int length, Content& result)
|
|
129
|
+
{
|
|
130
|
+
// Beginning from an initial state of the Alpha sub-mode
|
|
131
|
+
// The default compaction mode for PDF417 in effect at the start of each symbol shall always be Text
|
|
132
|
+
// Compaction mode Alpha sub-mode (uppercase alphabetic). A latch codeword from another mode to the Text
|
|
133
|
+
// Compaction mode shall always switch to the Text Compaction Alpha sub-mode.
|
|
134
|
+
Mode subMode = Mode::ALPHA;
|
|
135
|
+
Mode priorToShiftMode = Mode::ALPHA;
|
|
136
|
+
int i = 0;
|
|
137
|
+
while (i < length) {
|
|
138
|
+
int subModeCh = textCompactionData[i];
|
|
139
|
+
|
|
140
|
+
// Note only have ECI and MODE_SHIFT_TO_BYTE_COMPACTION_MODE function codewords in text compaction array
|
|
141
|
+
if (IsECI(subModeCh)) {
|
|
142
|
+
i = ProcessECI(textCompactionData, i + 1, length, subModeCh, result);
|
|
143
|
+
continue;
|
|
144
|
+
}
|
|
145
|
+
if (subModeCh == MODE_SHIFT_TO_BYTE_COMPACTION_MODE) {
|
|
146
|
+
i++;
|
|
147
|
+
while (i < length && IsECI(textCompactionData[i]))
|
|
148
|
+
i = ProcessECI(textCompactionData, i + 1, length, textCompactionData[i], result);
|
|
149
|
+
|
|
150
|
+
if (i < length)
|
|
151
|
+
result.push_back((uint8_t)textCompactionData[i++]);
|
|
152
|
+
|
|
153
|
+
continue;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
char ch = 0;
|
|
157
|
+
switch (subMode) {
|
|
158
|
+
case Mode::ALPHA:
|
|
159
|
+
case Mode::LOWER:
|
|
160
|
+
// Alpha (uppercase alphabetic) or Lower (lowercase alphabetic)
|
|
161
|
+
if (subModeCh < 26) {
|
|
162
|
+
// Upper/lowercase character
|
|
163
|
+
ch = (char)((subMode == Mode::ALPHA ? 'A' : 'a') + subModeCh);
|
|
164
|
+
} else if (subModeCh == 26) { // Space
|
|
165
|
+
ch = ' ';
|
|
166
|
+
} else if (subModeCh == 27 && subMode == Mode::ALPHA) { // LL
|
|
167
|
+
subMode = Mode::LOWER;
|
|
168
|
+
} else if (subModeCh == 27 && subMode == Mode::LOWER) { // AS
|
|
169
|
+
// Shift to alpha
|
|
170
|
+
priorToShiftMode = subMode;
|
|
171
|
+
subMode = Mode::ALPHA_SHIFT;
|
|
172
|
+
} else if (subModeCh == 28) { // ML
|
|
173
|
+
subMode = Mode::MIXED;
|
|
174
|
+
}
|
|
175
|
+
// 29 PS - ignore if last or followed by Shift to Byte, 5.4.2.4 (b) (1)
|
|
176
|
+
else if (i + 1 < length && textCompactionData[i + 1] != MODE_SHIFT_TO_BYTE_COMPACTION_MODE) {
|
|
177
|
+
// Shift to punctuation
|
|
178
|
+
priorToShiftMode = subMode;
|
|
179
|
+
subMode = Mode::PUNCT_SHIFT;
|
|
180
|
+
}
|
|
181
|
+
break;
|
|
182
|
+
|
|
183
|
+
case Mode::MIXED:
|
|
184
|
+
// Mixed (numeric and some punctuation)
|
|
185
|
+
if (subModeCh < 25) {
|
|
186
|
+
ch = MIXED_CHARS[subModeCh];
|
|
187
|
+
} else if (subModeCh == 25) { // PL
|
|
188
|
+
subMode = Mode::PUNCT;
|
|
189
|
+
} else if (subModeCh == 26) { // Space
|
|
190
|
+
ch = ' ';
|
|
191
|
+
} else if (subModeCh == 27) { // LL
|
|
192
|
+
subMode = Mode::LOWER;
|
|
193
|
+
} else if (subModeCh == 28) { // AL
|
|
194
|
+
subMode = Mode::ALPHA;
|
|
195
|
+
}
|
|
196
|
+
// 29 PS - ignore if last or followed by Shift to Byte, 5.4.2.4 (b) (1)
|
|
197
|
+
else if (i + 1 < length && textCompactionData[i + 1] != MODE_SHIFT_TO_BYTE_COMPACTION_MODE) {
|
|
198
|
+
// Shift to punctuation
|
|
199
|
+
priorToShiftMode = subMode;
|
|
200
|
+
subMode = Mode::PUNCT_SHIFT;
|
|
201
|
+
}
|
|
202
|
+
break;
|
|
203
|
+
|
|
204
|
+
case Mode::PUNCT:
|
|
205
|
+
// Punctuation
|
|
206
|
+
if (subModeCh < 29)
|
|
207
|
+
ch = PUNCT_CHARS[subModeCh];
|
|
208
|
+
else // 29 AL - note not ignored if followed by Shift to Byte, 5.4.2.4 (b) (2)
|
|
209
|
+
subMode = Mode::ALPHA;
|
|
210
|
+
break;
|
|
211
|
+
|
|
212
|
+
case Mode::ALPHA_SHIFT:
|
|
213
|
+
// Restore sub-mode
|
|
214
|
+
subMode = priorToShiftMode;
|
|
215
|
+
if (subModeCh < 26)
|
|
216
|
+
ch = (char)('A' + subModeCh);
|
|
217
|
+
else if (subModeCh == 26) // Space
|
|
218
|
+
ch = ' ';
|
|
219
|
+
// 27 LL, 28 ML, 29 PS used as padding
|
|
220
|
+
break;
|
|
221
|
+
|
|
222
|
+
case Mode::PUNCT_SHIFT:
|
|
223
|
+
// Restore sub-mode
|
|
224
|
+
subMode = priorToShiftMode;
|
|
225
|
+
if (subModeCh < 29)
|
|
226
|
+
ch = PUNCT_CHARS[subModeCh];
|
|
227
|
+
else // 29 AL
|
|
228
|
+
subMode = Mode::ALPHA;
|
|
229
|
+
break;
|
|
230
|
+
}
|
|
231
|
+
if (ch != 0)
|
|
232
|
+
result.push_back(ch); // Append decoded character to result
|
|
233
|
+
i++;
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
/*
|
|
238
|
+
* Helper to put ECI codewords into Text Compaction array.
|
|
239
|
+
*/
|
|
240
|
+
static int ProcessTextECI(std::vector<int>& textCompactionData, int& index, const std::vector<int>& codewords, int codeIndex,
|
|
241
|
+
const int code)
|
|
242
|
+
{
|
|
243
|
+
textCompactionData[index++] = code;
|
|
244
|
+
if (codeIndex < codewords[0]) {
|
|
245
|
+
textCompactionData[index++] = codewords[codeIndex++];
|
|
246
|
+
if (codeIndex < codewords[0] && code == ECI_GENERAL_PURPOSE) {
|
|
247
|
+
textCompactionData[index++] = codewords[codeIndex++];
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
return codeIndex;
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
/**
|
|
255
|
+
* Text Compaction mode (see 5.4.1.5) permits all printable ASCII characters to be
|
|
256
|
+
* encoded, i.e. values 32 - 126 inclusive in accordance with ISO/IEC 646 (IRV), as
|
|
257
|
+
* well as selected control characters.
|
|
258
|
+
*
|
|
259
|
+
* @param codewords The array of codewords (data + error)
|
|
260
|
+
* @param codeIndex The current index into the codeword array.
|
|
261
|
+
* @param result The data in the character set encoding.
|
|
262
|
+
* @return The next index into the codeword array.
|
|
263
|
+
*/
|
|
264
|
+
static int TextCompaction(const std::vector<int>& codewords, int codeIndex, Content& result)
|
|
265
|
+
{
|
|
266
|
+
// 2 characters per codeword
|
|
267
|
+
std::vector<int> textCompactionData((codewords[0] - codeIndex) * 2, 0);
|
|
268
|
+
|
|
269
|
+
int index = 0;
|
|
270
|
+
bool end = false;
|
|
271
|
+
|
|
272
|
+
while ((codeIndex < codewords[0]) && !end) {
|
|
273
|
+
int code = codewords[codeIndex++];
|
|
274
|
+
if (code < TEXT_COMPACTION_MODE_LATCH) {
|
|
275
|
+
textCompactionData[index] = code / 30;
|
|
276
|
+
textCompactionData[index + 1] = code % 30;
|
|
277
|
+
index += 2;
|
|
278
|
+
} else {
|
|
279
|
+
switch (code) {
|
|
280
|
+
case MODE_SHIFT_TO_BYTE_COMPACTION_MODE:
|
|
281
|
+
// The Mode Shift codeword 913 shall cause a temporary
|
|
282
|
+
// switch from Text Compaction mode to Byte Compaction mode.
|
|
283
|
+
// This switch shall be in effect for only the next codeword,
|
|
284
|
+
// after which the mode shall revert to the prevailing sub-mode
|
|
285
|
+
// of the Text Compaction mode. Codeword 913 is only available
|
|
286
|
+
// in Text Compaction mode; its use is described in 5.4.2.4.
|
|
287
|
+
textCompactionData[index++] = MODE_SHIFT_TO_BYTE_COMPACTION_MODE;
|
|
288
|
+
// 5.5.3.1 allows ECIs anywhere in Text Compaction, including after a Shift to Byte
|
|
289
|
+
while (codeIndex < codewords[0] && IsECI(codewords[codeIndex])) {
|
|
290
|
+
codeIndex = ProcessTextECI(textCompactionData, index, codewords, codeIndex + 1, codewords[codeIndex]);
|
|
291
|
+
}
|
|
292
|
+
if (codeIndex < codewords[0])
|
|
293
|
+
textCompactionData[index++] = codewords[codeIndex++]; // Byte to shift
|
|
294
|
+
break;
|
|
295
|
+
case ECI_CHARSET:
|
|
296
|
+
case ECI_GENERAL_PURPOSE:
|
|
297
|
+
case ECI_USER_DEFINED:
|
|
298
|
+
codeIndex = ProcessTextECI(textCompactionData, index, codewords, codeIndex, code);
|
|
299
|
+
break;
|
|
300
|
+
default:
|
|
301
|
+
if (!TerminatesCompaction(code))
|
|
302
|
+
throw FormatError();
|
|
303
|
+
|
|
304
|
+
codeIndex--;
|
|
305
|
+
end = true;
|
|
306
|
+
break;
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
DecodeTextCompaction(textCompactionData, index, result);
|
|
311
|
+
return codeIndex;
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
/*
|
|
315
|
+
* Helper for Byte Compaction to look ahead and count 5-codeword batches and trailing bytes, with some checking of
|
|
316
|
+
* format errors.
|
|
317
|
+
*/
|
|
318
|
+
static int CountByteBatches(int mode, const std::vector<int>& codewords, int codeIndex, int& trailingCount)
|
|
319
|
+
{
|
|
320
|
+
int count = 0;
|
|
321
|
+
trailingCount = 0;
|
|
322
|
+
|
|
323
|
+
while (codeIndex < codewords[0]) {
|
|
324
|
+
int code = codewords[codeIndex++];
|
|
325
|
+
if (code >= TEXT_COMPACTION_MODE_LATCH) {
|
|
326
|
+
if (mode == BYTE_COMPACTION_MODE_LATCH_6 && count && count % 5)
|
|
327
|
+
throw FormatError();
|
|
328
|
+
|
|
329
|
+
if (IsECI(code)) {
|
|
330
|
+
codeIndex += code == ECI_GENERAL_PURPOSE ? 2 : 1;
|
|
331
|
+
continue;
|
|
332
|
+
}
|
|
333
|
+
if (!TerminatesCompaction(code))
|
|
334
|
+
throw FormatError();
|
|
335
|
+
break;
|
|
336
|
+
}
|
|
337
|
+
count++;
|
|
338
|
+
}
|
|
339
|
+
if (codeIndex > codewords[0])
|
|
340
|
+
throw FormatError();
|
|
341
|
+
|
|
342
|
+
if (count == 0)
|
|
343
|
+
return 0;
|
|
344
|
+
|
|
345
|
+
if (mode == BYTE_COMPACTION_MODE_LATCH) {
|
|
346
|
+
trailingCount = count % 5;
|
|
347
|
+
if (trailingCount == 0) {
|
|
348
|
+
trailingCount = 5;
|
|
349
|
+
count -= 5;
|
|
350
|
+
}
|
|
351
|
+
} else { // BYTE_COMPACTION_MODE_LATCH_6
|
|
352
|
+
if (count % 5 != 0)
|
|
353
|
+
throw FormatError();
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
return count / 5;
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
/*
|
|
360
|
+
* Helper to handle Byte Compaction ECIs.
|
|
361
|
+
*/
|
|
362
|
+
static int ProcessByteECIs(const std::vector<int>& codewords, int codeIndex, Content& result)
|
|
363
|
+
{
|
|
364
|
+
while (codeIndex < codewords[0] && codewords[codeIndex] >= TEXT_COMPACTION_MODE_LATCH
|
|
365
|
+
&& !TerminatesCompaction(codewords[codeIndex])) {
|
|
366
|
+
int code = codewords[codeIndex++];
|
|
367
|
+
if (!IsECI(code))
|
|
368
|
+
throw FormatError();
|
|
369
|
+
codeIndex = ProcessECI(codewords, codeIndex, codewords[0], code, result);
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
return codeIndex;
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
/**
|
|
376
|
+
* Byte Compaction mode (see 5.4.3) permits all 256 possible 8-bit byte values to be encoded.
|
|
377
|
+
* This includes all ASCII characters value 0 to 127 inclusive and provides for international
|
|
378
|
+
* character set support.
|
|
379
|
+
*
|
|
380
|
+
* @param mode The byte compaction mode i.e. 901 or 924
|
|
381
|
+
* @param codewords The array of codewords (data + error)
|
|
382
|
+
* @param codeIndex The current index into the codeword array.
|
|
383
|
+
* @param result The data in the character set encoding.
|
|
384
|
+
* @return The next index into the codeword array.
|
|
385
|
+
*/
|
|
386
|
+
static int ByteCompaction(int mode, const std::vector<int>& codewords, int codeIndex, Content& result)
|
|
387
|
+
{
|
|
388
|
+
// Count number of 5-codeword batches and trailing bytes
|
|
389
|
+
int trailingCount;
|
|
390
|
+
int batches = CountByteBatches(mode, codewords, codeIndex, trailingCount);
|
|
391
|
+
|
|
392
|
+
// Deal with initial ECIs
|
|
393
|
+
codeIndex = ProcessByteECIs(codewords, codeIndex, result);
|
|
394
|
+
|
|
395
|
+
for (int batch = 0; batch < batches; batch++) {
|
|
396
|
+
int64_t value = 0;
|
|
397
|
+
for (int count = 0; count < 5; count++) {
|
|
398
|
+
// Per ISO/IEC 15438:2015 5.5.3.2, ECI shall not appear within a 5-codeword data group
|
|
399
|
+
if (codeIndex >= codewords[0] || codewords[codeIndex] >= TEXT_COMPACTION_MODE_LATCH)
|
|
400
|
+
throw FormatError();
|
|
401
|
+
value = 900 * value + codewords[codeIndex++];
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
for (int j = 0; j < 6; ++j)
|
|
405
|
+
result.push_back((uint8_t)(value >> (8 * (5 - j))));
|
|
406
|
+
|
|
407
|
+
// Deal with inter-batch ECIs
|
|
408
|
+
codeIndex = ProcessByteECIs(codewords, codeIndex, result);
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
for (int i = 0; i < trailingCount && codeIndex < codewords[0]; i++) {
|
|
412
|
+
result.push_back((uint8_t)codewords[codeIndex++]);
|
|
413
|
+
// Deal with inter-byte ECIs
|
|
414
|
+
codeIndex = ProcessByteECIs(codewords, codeIndex, result);
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
return codeIndex;
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
|
|
421
|
+
/**
|
|
422
|
+
* Convert a list of Numeric Compacted codewords from Base 900 to Base 10.
|
|
423
|
+
*
|
|
424
|
+
* @param codewords The array of codewords
|
|
425
|
+
* @param count The number of codewords
|
|
426
|
+
* @return The decoded string representing the Numeric data.
|
|
427
|
+
*/
|
|
428
|
+
/*
|
|
429
|
+
EXAMPLE
|
|
430
|
+
Encode the fifteen digit numeric string 000213298174000
|
|
431
|
+
Prefix the numeric string with a 1 and set the initial value of
|
|
432
|
+
t = 1 000 213 298 174 000
|
|
433
|
+
Calculate codeword 0
|
|
434
|
+
d0 = 1 000 213 298 174 000 mod 900 = 200
|
|
435
|
+
|
|
436
|
+
t = 1 000 213 298 174 000 div 900 = 1 111 348 109 082
|
|
437
|
+
Calculate codeword 1
|
|
438
|
+
d1 = 1 111 348 109 082 mod 900 = 282
|
|
439
|
+
|
|
440
|
+
t = 1 111 348 109 082 div 900 = 1 234 831 232
|
|
441
|
+
Calculate codeword 2
|
|
442
|
+
d2 = 1 234 831 232 mod 900 = 632
|
|
443
|
+
|
|
444
|
+
t = 1 234 831 232 div 900 = 1 372 034
|
|
445
|
+
Calculate codeword 3
|
|
446
|
+
d3 = 1 372 034 mod 900 = 434
|
|
447
|
+
|
|
448
|
+
t = 1 372 034 div 900 = 1 524
|
|
449
|
+
Calculate codeword 4
|
|
450
|
+
d4 = 1 524 mod 900 = 624
|
|
451
|
+
|
|
452
|
+
t = 1 524 div 900 = 1
|
|
453
|
+
Calculate codeword 5
|
|
454
|
+
d5 = 1 mod 900 = 1
|
|
455
|
+
t = 1 div 900 = 0
|
|
456
|
+
Codeword sequence is: 1, 624, 434, 632, 282, 200
|
|
457
|
+
|
|
458
|
+
Decode the above codewords involves
|
|
459
|
+
1 x 900 power of 5 + 624 x 900 power of 4 + 434 x 900 power of 3 +
|
|
460
|
+
632 x 900 power of 2 + 282 x 900 power of 1 + 200 x 900 power of 0 = 1000213298174000
|
|
461
|
+
|
|
462
|
+
Remove leading 1 => Result is 000213298174000
|
|
463
|
+
*/
|
|
464
|
+
static std::string DecodeBase900toBase10(const std::vector<int>& codewords, int endIndex, int count)
|
|
465
|
+
{
|
|
466
|
+
// Table containing values for the exponent of 900.
|
|
467
|
+
static const auto EXP900 = []() {
|
|
468
|
+
std::array<BigInteger, 16> table = {1, 900};
|
|
469
|
+
for (size_t i = 2; i < table.size(); ++i)
|
|
470
|
+
table[i] = table[i - 1] * 900;
|
|
471
|
+
return table;
|
|
472
|
+
}();
|
|
473
|
+
|
|
474
|
+
assert(count <= 16);
|
|
475
|
+
|
|
476
|
+
BigInteger result;
|
|
477
|
+
for (int i = 0; i < count; i++)
|
|
478
|
+
result += EXP900[count - i - 1] * codewords[endIndex - count + i];
|
|
479
|
+
|
|
480
|
+
std::string resultString = result.toString();
|
|
481
|
+
if (!resultString.empty() && resultString.front() == '1')
|
|
482
|
+
return resultString.substr(1);
|
|
483
|
+
|
|
484
|
+
throw FormatError();
|
|
485
|
+
}
|
|
486
|
+
|
|
487
|
+
|
|
488
|
+
/**
|
|
489
|
+
* Numeric Compaction mode (see 5.4.4) permits efficient encoding of numeric data strings.
|
|
490
|
+
*
|
|
491
|
+
* @param codewords The array of codewords (data + error)
|
|
492
|
+
* @param codeIndex The current index into the codeword array.
|
|
493
|
+
* @param result The decoded data is appended to the result.
|
|
494
|
+
* @return The next index into the codeword array.
|
|
495
|
+
*/
|
|
496
|
+
static int NumericCompaction(const std::vector<int>& codewords, int codeIndex, Content& result)
|
|
497
|
+
{
|
|
498
|
+
int count = 0;
|
|
499
|
+
|
|
500
|
+
while (codeIndex < codewords[0]) {
|
|
501
|
+
int code = codewords[codeIndex];
|
|
502
|
+
if (code < TEXT_COMPACTION_MODE_LATCH) {
|
|
503
|
+
count++;
|
|
504
|
+
codeIndex++;
|
|
505
|
+
}
|
|
506
|
+
if (count > 0 && (count == MAX_NUMERIC_CODEWORDS || codeIndex == codewords[0] || code >= TEXT_COMPACTION_MODE_LATCH)) {
|
|
507
|
+
result.append(DecodeBase900toBase10(codewords, codeIndex, count));
|
|
508
|
+
count = 0;
|
|
509
|
+
}
|
|
510
|
+
|
|
511
|
+
if (code >= TEXT_COMPACTION_MODE_LATCH) {
|
|
512
|
+
if (IsECI(code)) {
|
|
513
|
+
// As operating in Basic Channel Mode (i.e. not embedding backslashed ECIs and doubling backslashes)
|
|
514
|
+
// allow ECIs anywhere in Numeric Compaction (i.e. ISO/IEC 15438:2015 5.5.3.4 doesn't apply).
|
|
515
|
+
codeIndex = ProcessECI(codewords, codeIndex + 1, codewords[0], code, result);
|
|
516
|
+
} else if (TerminatesCompaction(code)) {
|
|
517
|
+
break;
|
|
518
|
+
} else {
|
|
519
|
+
throw FormatError();
|
|
520
|
+
}
|
|
521
|
+
}
|
|
522
|
+
}
|
|
523
|
+
return codeIndex;
|
|
524
|
+
}
|
|
525
|
+
|
|
526
|
+
/*
|
|
527
|
+
* Helper to deal with optional text fields in Macros.
|
|
528
|
+
*/
|
|
529
|
+
static int DecodeMacroOptionalTextField(const std::vector<int>& codewords, int codeIndex, std::string& field)
|
|
530
|
+
{
|
|
531
|
+
Content result;
|
|
532
|
+
// Each optional field begins with an implied reset to ECI 2 (Annex H.2.3). ECI 2 is ASCII for 0-127, and Cp437
|
|
533
|
+
// for non-ASCII (128-255). Text optional fields can contain ECIs.
|
|
534
|
+
result.defaultCharset = CharacterSet::Cp437;
|
|
535
|
+
|
|
536
|
+
codeIndex = TextCompaction(codewords, codeIndex, result);
|
|
537
|
+
|
|
538
|
+
// Converting to UTF-8 (backward-incompatible change for non-ASCII chars)
|
|
539
|
+
field = result.utf8();
|
|
540
|
+
|
|
541
|
+
return codeIndex;
|
|
542
|
+
}
|
|
543
|
+
|
|
544
|
+
/*
|
|
545
|
+
* Helper to deal with optional numeric fields in Macros.
|
|
546
|
+
*/
|
|
547
|
+
template<typename T>
|
|
548
|
+
int DecodeMacroOptionalNumericField(const std::vector<int>& codewords, int codeIndex, T& field)
|
|
549
|
+
{
|
|
550
|
+
Content result;
|
|
551
|
+
// Each optional field begins with an implied reset to ECI 2 (Annex H.2.3). ECI 2 is ASCII for 0-127, and Cp437
|
|
552
|
+
// for non-ASCII (128-255). Text optional fields can contain ECIs.
|
|
553
|
+
result.defaultCharset = CharacterSet::Cp437;
|
|
554
|
+
|
|
555
|
+
codeIndex = NumericCompaction(codewords, codeIndex, result);
|
|
556
|
+
|
|
557
|
+
auto txt = result.utf8();
|
|
558
|
+
if (std::from_chars(txt.data(), txt.data()+txt.size(), field).ec != std::errc())
|
|
559
|
+
throw FormatError();
|
|
560
|
+
|
|
561
|
+
return codeIndex;
|
|
562
|
+
}
|
|
563
|
+
|
|
564
|
+
ZXING_EXPORT_TEST_ONLY
|
|
565
|
+
int DecodeMacroBlock(const std::vector<int>& codewords, int codeIndex, PDF417CustomData& customData)
|
|
566
|
+
{
|
|
567
|
+
// we must have at least two codewords left for the segment index
|
|
568
|
+
if (codeIndex + NUMBER_OF_SEQUENCE_CODEWORDS > codewords[0])
|
|
569
|
+
throw FormatError();
|
|
570
|
+
|
|
571
|
+
std::string strBuf = DecodeBase900toBase10(codewords, codeIndex += NUMBER_OF_SEQUENCE_CODEWORDS, NUMBER_OF_SEQUENCE_CODEWORDS);
|
|
572
|
+
|
|
573
|
+
customData.segmentIndex = std::stoi(strBuf);
|
|
574
|
+
|
|
575
|
+
// Decoding the fileId codewords as 0-899 numbers, each 0-filled to width 3. This follows the spec
|
|
576
|
+
// (See ISO/IEC 15438:2015 Annex H.6) and preserves all info, but some generators (e.g. TEC-IT) write
|
|
577
|
+
// the fileId using text compaction, so in those cases the fileId will appear mangled.
|
|
578
|
+
std::ostringstream fileId;
|
|
579
|
+
for (; codeIndex < codewords[0] && codewords[codeIndex] != MACRO_PDF417_TERMINATOR
|
|
580
|
+
&& codewords[codeIndex] != BEGIN_MACRO_PDF417_OPTIONAL_FIELD;
|
|
581
|
+
codeIndex++) {
|
|
582
|
+
fileId << ToString(codewords[codeIndex], 3);
|
|
583
|
+
}
|
|
584
|
+
customData.fileId = fileId.str();
|
|
585
|
+
|
|
586
|
+
int optionalFieldsStart = -1;
|
|
587
|
+
if (codeIndex < codewords[0] && codewords[codeIndex] == BEGIN_MACRO_PDF417_OPTIONAL_FIELD)
|
|
588
|
+
optionalFieldsStart = codeIndex + 1;
|
|
589
|
+
|
|
590
|
+
while (codeIndex < codewords[0]) {
|
|
591
|
+
switch (codewords[codeIndex]) {
|
|
592
|
+
case BEGIN_MACRO_PDF417_OPTIONAL_FIELD: {
|
|
593
|
+
codeIndex++;
|
|
594
|
+
if (codeIndex >= codewords[0])
|
|
595
|
+
break;
|
|
596
|
+
switch (codewords[codeIndex]) {
|
|
597
|
+
case MACRO_PDF417_OPTIONAL_FIELD_FILE_NAME:
|
|
598
|
+
codeIndex = DecodeMacroOptionalTextField(codewords, codeIndex + 1, customData.fileName);
|
|
599
|
+
break;
|
|
600
|
+
case MACRO_PDF417_OPTIONAL_FIELD_SENDER:
|
|
601
|
+
codeIndex = DecodeMacroOptionalTextField(codewords, codeIndex + 1, customData.sender);
|
|
602
|
+
break;
|
|
603
|
+
case MACRO_PDF417_OPTIONAL_FIELD_ADDRESSEE:
|
|
604
|
+
codeIndex = DecodeMacroOptionalTextField(codewords, codeIndex + 1, customData.addressee);
|
|
605
|
+
break;
|
|
606
|
+
case MACRO_PDF417_OPTIONAL_FIELD_SEGMENT_COUNT:
|
|
607
|
+
codeIndex = DecodeMacroOptionalNumericField(codewords, codeIndex + 1, customData.segmentCount);
|
|
608
|
+
break;
|
|
609
|
+
case MACRO_PDF417_OPTIONAL_FIELD_TIME_STAMP:
|
|
610
|
+
codeIndex = DecodeMacroOptionalNumericField(codewords, codeIndex + 1, customData.timestamp);
|
|
611
|
+
break;
|
|
612
|
+
case MACRO_PDF417_OPTIONAL_FIELD_CHECKSUM:
|
|
613
|
+
codeIndex = DecodeMacroOptionalNumericField(codewords, codeIndex + 1, customData.checksum);
|
|
614
|
+
break;
|
|
615
|
+
case MACRO_PDF417_OPTIONAL_FIELD_FILE_SIZE:
|
|
616
|
+
codeIndex = DecodeMacroOptionalNumericField(codewords, codeIndex + 1, customData.fileSize);
|
|
617
|
+
break;
|
|
618
|
+
default: throw FormatError();
|
|
619
|
+
}
|
|
620
|
+
break;
|
|
621
|
+
}
|
|
622
|
+
case MACRO_PDF417_TERMINATOR: {
|
|
623
|
+
codeIndex++;
|
|
624
|
+
customData.isLastSegment = true;
|
|
625
|
+
break;
|
|
626
|
+
}
|
|
627
|
+
default: throw FormatError();
|
|
628
|
+
}
|
|
629
|
+
}
|
|
630
|
+
|
|
631
|
+
// copy optional fields to additional options
|
|
632
|
+
if (optionalFieldsStart != -1) {
|
|
633
|
+
int optionalFieldsLength = codeIndex - optionalFieldsStart;
|
|
634
|
+
if (customData.isLastSegment)
|
|
635
|
+
optionalFieldsLength--; // do not include terminator
|
|
636
|
+
|
|
637
|
+
customData.optionalData =
|
|
638
|
+
std::vector<int>(codewords.begin() + optionalFieldsStart, codewords.begin() + optionalFieldsStart + optionalFieldsLength);
|
|
639
|
+
}
|
|
640
|
+
|
|
641
|
+
return codeIndex;
|
|
642
|
+
}
|
|
643
|
+
|
|
644
|
+
DecoderResult Decode(const std::vector<int>& codewords)
|
|
645
|
+
{
|
|
646
|
+
if (codewords.empty() || codewords[0] < 1 || codewords[0] > Size(codewords))
|
|
647
|
+
return FormatError();
|
|
648
|
+
|
|
649
|
+
Content result;
|
|
650
|
+
result.symbology = {'L', '2', -1};
|
|
651
|
+
|
|
652
|
+
bool readerInit = false;
|
|
653
|
+
auto customData = std::make_shared<PDF417CustomData>();
|
|
654
|
+
|
|
655
|
+
try {
|
|
656
|
+
for (int codeIndex = 1; codeIndex < codewords[0];) {
|
|
657
|
+
int code = codewords[codeIndex++];
|
|
658
|
+
switch (code) {
|
|
659
|
+
case TEXT_COMPACTION_MODE_LATCH: codeIndex = TextCompaction(codewords, codeIndex, result); break;
|
|
660
|
+
// This should only be encountered once in this loop, when default Text Compaction mode applies
|
|
661
|
+
// (see default case below)
|
|
662
|
+
case MODE_SHIFT_TO_BYTE_COMPACTION_MODE: codeIndex = TextCompaction(codewords, codeIndex - 1, result); break;
|
|
663
|
+
case BYTE_COMPACTION_MODE_LATCH:
|
|
664
|
+
case BYTE_COMPACTION_MODE_LATCH_6: codeIndex = ByteCompaction(code, codewords, codeIndex, result); break;
|
|
665
|
+
case NUMERIC_COMPACTION_MODE_LATCH: codeIndex = NumericCompaction(codewords, codeIndex, result); break;
|
|
666
|
+
case ECI_CHARSET:
|
|
667
|
+
case ECI_GENERAL_PURPOSE:
|
|
668
|
+
case ECI_USER_DEFINED: codeIndex = ProcessECI(codewords, codeIndex, codewords[0], code, result); break;
|
|
669
|
+
case BEGIN_MACRO_PDF417_CONTROL_BLOCK: codeIndex = DecodeMacroBlock(codewords, codeIndex, *customData); break;
|
|
670
|
+
case BEGIN_MACRO_PDF417_OPTIONAL_FIELD:
|
|
671
|
+
case MACRO_PDF417_TERMINATOR:
|
|
672
|
+
// Should not see these outside a macro block
|
|
673
|
+
throw FormatError();
|
|
674
|
+
break;
|
|
675
|
+
case READER_INIT:
|
|
676
|
+
if (codeIndex != 2) // Must be first codeword after symbol length (ISO/IEC 15438:2015 5.4.1.4)
|
|
677
|
+
throw FormatError();
|
|
678
|
+
else
|
|
679
|
+
readerInit = true;
|
|
680
|
+
break;
|
|
681
|
+
case LINKAGE_EANUCC:
|
|
682
|
+
if (codeIndex != 2) // Must be first codeword after symbol length (GS1 Composite ISO/IEC 24723:2010 4.3)
|
|
683
|
+
throw FormatError();
|
|
684
|
+
// TODO: handle else case
|
|
685
|
+
break;
|
|
686
|
+
case LINKAGE_OTHER:
|
|
687
|
+
// Allowed to treat as invalid by ISO/IEC 24723:2010 5.4.1.5 and 5.4.6.1 when in Basic Channel Mode
|
|
688
|
+
throw UnsupportedError("LINKAGE_OTHER, see ISO/IEC 15438:2015 5.4.1.5");
|
|
689
|
+
break;
|
|
690
|
+
default:
|
|
691
|
+
if (code >= TEXT_COMPACTION_MODE_LATCH) { // Reserved codewords (all others in switch)
|
|
692
|
+
// Allowed to treat as invalid by ISO/IEC 24723:2010 5.4.6.1 when in Basic Channel Mode
|
|
693
|
+
throw UnsupportedError("Reserved codeword, see ISO/IEC 15438:2015 5.4.6.1");
|
|
694
|
+
} else {
|
|
695
|
+
// Default mode is Text Compaction mode Alpha sub-mode (ISO/IEC 15438:2015 5.4.2.1)
|
|
696
|
+
codeIndex = TextCompaction(codewords, codeIndex - 1, result);
|
|
697
|
+
}
|
|
698
|
+
break;
|
|
699
|
+
}
|
|
700
|
+
}
|
|
701
|
+
} catch (std::exception& e) {
|
|
702
|
+
return FormatError(e.what());
|
|
703
|
+
} catch (Error e) {
|
|
704
|
+
return e;
|
|
705
|
+
}
|
|
706
|
+
|
|
707
|
+
if (result.empty() && customData->segmentIndex == -1)
|
|
708
|
+
return FormatError();
|
|
709
|
+
|
|
710
|
+
StructuredAppendInfo sai;
|
|
711
|
+
if (customData->segmentIndex > -1) {
|
|
712
|
+
sai.count = customData->segmentCount != -1
|
|
713
|
+
? customData->segmentCount
|
|
714
|
+
: (customData->isLastSegment ? customData->segmentIndex + 1 : 0);
|
|
715
|
+
sai.index = customData->segmentIndex;
|
|
716
|
+
sai.id = customData->fileId;
|
|
717
|
+
}
|
|
718
|
+
|
|
719
|
+
return DecoderResult(std::move(result))
|
|
720
|
+
.setStructuredAppend(sai)
|
|
721
|
+
.setReaderInit(readerInit)
|
|
722
|
+
.setCustomData(customData);
|
|
723
|
+
}
|
|
724
|
+
|
|
725
|
+
} // namespace ZXing::Pdf417
|