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,52 @@
|
|
|
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
|
+
#include "ByteArray.h"
|
|
10
|
+
|
|
11
|
+
#include <vector>
|
|
12
|
+
|
|
13
|
+
namespace ZXing::QRCode {
|
|
14
|
+
|
|
15
|
+
class Version;
|
|
16
|
+
enum class ErrorCorrectionLevel;
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* <p>Encapsulates a block of data within a QR Code. QR Codes may split their data into
|
|
20
|
+
* multiple blocks, each of which is a unit of data and error-correction codewords. Each
|
|
21
|
+
* is represented by an instance of this class.</p>
|
|
22
|
+
*
|
|
23
|
+
* @author Sean Owen
|
|
24
|
+
*/
|
|
25
|
+
class DataBlock
|
|
26
|
+
{
|
|
27
|
+
public:
|
|
28
|
+
int numDataCodewords() const { return _numDataCodewords; }
|
|
29
|
+
|
|
30
|
+
const ByteArray& codewords() const { return _codewords; }
|
|
31
|
+
|
|
32
|
+
ByteArray& codewords() { return _codewords; }
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* <p>When QR Codes use multiple data blocks, they are actually interleaved.
|
|
36
|
+
* That is, the first byte of data block 1 to n is written, then the second bytes, and so on. This
|
|
37
|
+
* method will separate the data into original blocks.</p>
|
|
38
|
+
*
|
|
39
|
+
* @param rawCodewords bytes as read directly from the QR Code
|
|
40
|
+
* @param version version of the QR Code
|
|
41
|
+
* @param ecLevel error-correction level of the QR Code
|
|
42
|
+
* @return DataBlocks containing original bytes, "de-interleaved" from representation in the
|
|
43
|
+
* QR Code
|
|
44
|
+
*/
|
|
45
|
+
static std::vector<DataBlock> GetDataBlocks(const ByteArray& rawCodewords, const Version& version, ErrorCorrectionLevel ecLevel);
|
|
46
|
+
|
|
47
|
+
private:
|
|
48
|
+
int _numDataCodewords = 0;
|
|
49
|
+
ByteArray _codewords;
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
} // namespace ZXing::QRCode
|
|
@@ -0,0 +1,50 @@
|
|
|
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
|
+
#include "BitMatrix.h"
|
|
10
|
+
|
|
11
|
+
#include <array>
|
|
12
|
+
#include <stdexcept>
|
|
13
|
+
|
|
14
|
+
namespace ZXing::QRCode {
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* <p>Encapsulates data masks for the data bits in a QR and micro QR code, per ISO 18004:2006 6.8.</p>
|
|
18
|
+
*
|
|
19
|
+
* <p>Note that the diagram in section 6.8.1 is misleading since it indicates that i is column position
|
|
20
|
+
* and j is row position. In fact, as the text says, i is row position and j is column position.</p>
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
inline bool GetDataMaskBit(int maskIndex, int x, int y, bool isMicro = false)
|
|
24
|
+
{
|
|
25
|
+
if (isMicro) {
|
|
26
|
+
if (maskIndex < 0 || maskIndex >= 4)
|
|
27
|
+
throw std::invalid_argument("QRCode maskIndex out of range");
|
|
28
|
+
maskIndex = std::array{1, 4, 6, 7}[maskIndex]; // map from MQR to QR indices
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
switch (maskIndex) {
|
|
32
|
+
case 0: return (y + x) % 2 == 0;
|
|
33
|
+
case 1: return y % 2 == 0;
|
|
34
|
+
case 2: return x % 3 == 0;
|
|
35
|
+
case 3: return (y + x) % 3 == 0;
|
|
36
|
+
case 4: return ((y / 2) + (x / 3)) % 2 == 0;
|
|
37
|
+
case 5: return (y * x) % 6 == 0;
|
|
38
|
+
case 6: return ((y * x) % 6) < 3;
|
|
39
|
+
case 7: return (y + x + ((y * x) % 3)) % 2 == 0;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
throw std::invalid_argument("QRCode maskIndex out of range");
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
inline bool GetMaskedBit(const BitMatrix& bits, int x, int y, int maskIndex, bool isMicro = false)
|
|
46
|
+
{
|
|
47
|
+
return GetDataMaskBit(maskIndex, x, y, isMicro) != bits.get(x, y);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
} // namespace ZXing::QRCode
|
|
@@ -0,0 +1,359 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2016 Nu-book Inc.
|
|
3
|
+
* Copyright 2016 ZXing authors
|
|
4
|
+
*/
|
|
5
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
6
|
+
|
|
7
|
+
#include "QRDecoder.h"
|
|
8
|
+
|
|
9
|
+
#include "Barcode.h"
|
|
10
|
+
#include "BitMatrix.h"
|
|
11
|
+
#include "BitSource.h"
|
|
12
|
+
#include "ByteArray.h"
|
|
13
|
+
#include "CharacterSet.h"
|
|
14
|
+
#include "DecoderResult.h"
|
|
15
|
+
#include "QRBitMatrixParser.h"
|
|
16
|
+
#include "QRCodecMode.h"
|
|
17
|
+
#include "QRDataBlock.h"
|
|
18
|
+
#include "QRFormatInformation.h"
|
|
19
|
+
#include "QRVersion.h"
|
|
20
|
+
#include "ReedSolomon.h"
|
|
21
|
+
#include "StructuredAppend.h"
|
|
22
|
+
#include "ZXAlgorithms.h"
|
|
23
|
+
#include "ZXTestSupport.h"
|
|
24
|
+
|
|
25
|
+
#include <algorithm>
|
|
26
|
+
#include <stdexcept>
|
|
27
|
+
#include <utility>
|
|
28
|
+
#include <vector>
|
|
29
|
+
|
|
30
|
+
namespace ZXing::QRCode {
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* See specification GBT 18284-2000
|
|
34
|
+
*/
|
|
35
|
+
static void DecodeHanziSegment(BitSource& bits, int count, Content& result)
|
|
36
|
+
{
|
|
37
|
+
// Each character will require 2 bytes, decode as GB2312
|
|
38
|
+
// There is no ECI value for GB2312, use GB18030 which is a superset
|
|
39
|
+
result.switchEncoding(CharacterSet::GB18030);
|
|
40
|
+
result.reserve(2 * count);
|
|
41
|
+
|
|
42
|
+
while (count > 0) {
|
|
43
|
+
// Each 13 bits encodes a 2-byte character
|
|
44
|
+
int twoBytes = bits.readBits(13);
|
|
45
|
+
int assembledTwoBytes = ((twoBytes / 0x060) << 8) | (twoBytes % 0x060);
|
|
46
|
+
if (assembledTwoBytes < 0x00A00) {
|
|
47
|
+
// In the 0xA1A1 to 0xAAFE range
|
|
48
|
+
assembledTwoBytes += 0x0A1A1;
|
|
49
|
+
} else {
|
|
50
|
+
// In the 0xB0A1 to 0xFAFE range
|
|
51
|
+
assembledTwoBytes += 0x0A6A1;
|
|
52
|
+
}
|
|
53
|
+
result.push_back((assembledTwoBytes >> 8) & 0xFF);
|
|
54
|
+
result.push_back(assembledTwoBytes & 0xFF);
|
|
55
|
+
count--;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
static void DecodeKanjiSegment(BitSource& bits, int count, Content& result)
|
|
60
|
+
{
|
|
61
|
+
// Each character will require 2 bytes. Read the characters as 2-byte pairs
|
|
62
|
+
// and decode as Shift_JIS afterwards
|
|
63
|
+
result.switchEncoding(CharacterSet::Shift_JIS);
|
|
64
|
+
result.reserve(2 * count);
|
|
65
|
+
|
|
66
|
+
while (count > 0) {
|
|
67
|
+
// Each 13 bits encodes a 2-byte character
|
|
68
|
+
int twoBytes = bits.readBits(13);
|
|
69
|
+
int assembledTwoBytes = ((twoBytes / 0x0C0) << 8) | (twoBytes % 0x0C0);
|
|
70
|
+
if (assembledTwoBytes < 0x01F00) {
|
|
71
|
+
// In the 0x8140 to 0x9FFC range
|
|
72
|
+
assembledTwoBytes += 0x08140;
|
|
73
|
+
} else {
|
|
74
|
+
// In the 0xE040 to 0xEBBF range
|
|
75
|
+
assembledTwoBytes += 0x0C140;
|
|
76
|
+
}
|
|
77
|
+
result.push_back(assembledTwoBytes >> 8);
|
|
78
|
+
result.push_back(assembledTwoBytes);
|
|
79
|
+
count--;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
static void DecodeByteSegment(BitSource& bits, int count, Content& result)
|
|
84
|
+
{
|
|
85
|
+
result.switchEncoding(CharacterSet::Unknown);
|
|
86
|
+
result.reserve(count);
|
|
87
|
+
|
|
88
|
+
for (int i = 0; i < count; i++)
|
|
89
|
+
result.push_back(bits.readBits(8));
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
static char ToAlphaNumericChar(int value)
|
|
93
|
+
{
|
|
94
|
+
/**
|
|
95
|
+
* See ISO 18004:2006, 6.4.4 Table 5
|
|
96
|
+
*/
|
|
97
|
+
constexpr std::array ALPHANUMERIC_CHARS = {
|
|
98
|
+
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B',
|
|
99
|
+
'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N',
|
|
100
|
+
'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z',
|
|
101
|
+
' ', '$', '%', '*', '+', '-', '.', '/', ':'
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
return ALPHANUMERIC_CHARS.at(value);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
static void DecodeAlphanumericSegment(BitSource& bits, int count, Content& result)
|
|
108
|
+
{
|
|
109
|
+
// Read two characters at a time
|
|
110
|
+
std::string buffer;
|
|
111
|
+
while (count > 1) {
|
|
112
|
+
int nextTwoCharsBits = bits.readBits(11);
|
|
113
|
+
buffer += ToAlphaNumericChar(nextTwoCharsBits / 45);
|
|
114
|
+
buffer += ToAlphaNumericChar(nextTwoCharsBits % 45);
|
|
115
|
+
count -= 2;
|
|
116
|
+
}
|
|
117
|
+
if (count == 1) {
|
|
118
|
+
// special case: one character left
|
|
119
|
+
buffer += ToAlphaNumericChar(bits.readBits(6));
|
|
120
|
+
}
|
|
121
|
+
// See section 6.4.8.1, 6.4.8.2
|
|
122
|
+
if (result.symbology.aiFlag != AIFlag::None) {
|
|
123
|
+
// We need to massage the result a bit if in an FNC1 mode:
|
|
124
|
+
for (auto i = buffer.begin(); i != buffer.end(); i++) {
|
|
125
|
+
if (*i == '%') {
|
|
126
|
+
if (i + 1 != buffer.end() && *(i + 1) == '%') {
|
|
127
|
+
// %% is rendered as %
|
|
128
|
+
i = buffer.erase(i);
|
|
129
|
+
} else {
|
|
130
|
+
// In alpha mode, % should be converted to FNC1 separator 0x1D
|
|
131
|
+
*i = static_cast<char>(0x1D);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
result.switchEncoding(CharacterSet::ISO8859_1);
|
|
138
|
+
result.append(buffer);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
static void DecodeNumericSegment(BitSource& bits, int count, Content& result)
|
|
142
|
+
{
|
|
143
|
+
result.switchEncoding(CharacterSet::ISO8859_1);
|
|
144
|
+
result.reserve(count);
|
|
145
|
+
|
|
146
|
+
while (count) {
|
|
147
|
+
int n = std::min(count, 3);
|
|
148
|
+
int nDigits = bits.readBits(1 + 3 * n); // read 4, 7 or 10 bits into 1, 2 or 3 digits
|
|
149
|
+
result.append(ZXing::ToString(nDigits, n));
|
|
150
|
+
count -= n;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
static ECI ParseECIValue(BitSource& bits)
|
|
155
|
+
{
|
|
156
|
+
int firstByte = bits.readBits(8);
|
|
157
|
+
if ((firstByte & 0x80) == 0) {
|
|
158
|
+
// just one byte
|
|
159
|
+
return ECI(firstByte & 0x7F);
|
|
160
|
+
}
|
|
161
|
+
if ((firstByte & 0xC0) == 0x80) {
|
|
162
|
+
// two bytes
|
|
163
|
+
int secondByte = bits.readBits(8);
|
|
164
|
+
return ECI(((firstByte & 0x3F) << 8) | secondByte);
|
|
165
|
+
}
|
|
166
|
+
if ((firstByte & 0xE0) == 0xC0) {
|
|
167
|
+
// three bytes
|
|
168
|
+
int secondThirdBytes = bits.readBits(16);
|
|
169
|
+
return ECI(((firstByte & 0x1F) << 16) | secondThirdBytes);
|
|
170
|
+
}
|
|
171
|
+
throw FormatError("ParseECIValue: invalid value");
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* QR codes encode mode indicators and terminator codes into a constant bit length of 4.
|
|
176
|
+
* Micro QR codes have terminator codes that vary in bit length but are always longer than
|
|
177
|
+
* the mode indicators.
|
|
178
|
+
* M1 - 0 length mode code, 3 bits terminator code
|
|
179
|
+
* M2 - 1 bit mode code, 5 bits terminator code
|
|
180
|
+
* M3 - 2 bit mode code, 7 bits terminator code
|
|
181
|
+
* M4 - 3 bit mode code, 9 bits terminator code
|
|
182
|
+
* IsTerminator peeks into the bit stream to see if the current position is at the start of
|
|
183
|
+
* a terminator code. If true, then the decoding can finish. If false, then the decoding
|
|
184
|
+
* can read off the next mode code.
|
|
185
|
+
*
|
|
186
|
+
* See ISO 18004:2015, 7.4.1 Table 2
|
|
187
|
+
*
|
|
188
|
+
* @param bits the stream of bits that might have a terminator code
|
|
189
|
+
* @param version the QR or micro QR code version
|
|
190
|
+
*/
|
|
191
|
+
bool IsEndOfStream(const BitSource& bits, const Version& version)
|
|
192
|
+
{
|
|
193
|
+
const int bitsRequired = TerminatorBitsLength(version);
|
|
194
|
+
const int bitsAvailable = std::min(bits.available(), bitsRequired);
|
|
195
|
+
return bitsAvailable == 0 || bits.peekBits(bitsAvailable) == 0;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
/**
|
|
199
|
+
* <p>QR Codes can encode text as bits in one of several modes, and can use multiple modes
|
|
200
|
+
* in one QR Code. This method decodes the bits back into text.</p>
|
|
201
|
+
*
|
|
202
|
+
* <p>See ISO 18004:2006, 6.4.3 - 6.4.7</p>
|
|
203
|
+
*/
|
|
204
|
+
ZXING_EXPORT_TEST_ONLY
|
|
205
|
+
DecoderResult DecodeBitStream(ByteArray&& bytes, const Version& version, ErrorCorrectionLevel ecLevel)
|
|
206
|
+
{
|
|
207
|
+
BitSource bits(bytes);
|
|
208
|
+
Content result;
|
|
209
|
+
Error error;
|
|
210
|
+
result.symbology = {'Q', version.isModel1() ? '0' : '1', 1};
|
|
211
|
+
StructuredAppendInfo structuredAppend;
|
|
212
|
+
const int modeBitLength = CodecModeBitsLength(version);
|
|
213
|
+
|
|
214
|
+
if (version.isModel1())
|
|
215
|
+
bits.readBits(4); // Model 1 is leading with 4 0-bits -> drop them
|
|
216
|
+
|
|
217
|
+
try
|
|
218
|
+
{
|
|
219
|
+
while(!IsEndOfStream(bits, version)) {
|
|
220
|
+
CodecMode mode;
|
|
221
|
+
if (modeBitLength == 0)
|
|
222
|
+
mode = CodecMode::NUMERIC; // MicroQRCode version 1 is always NUMERIC and modeBitLength is 0
|
|
223
|
+
else
|
|
224
|
+
mode = CodecModeForBits(bits.readBits(modeBitLength), version.type());
|
|
225
|
+
|
|
226
|
+
switch (mode) {
|
|
227
|
+
case CodecMode::FNC1_FIRST_POSITION:
|
|
228
|
+
// if (!result.empty()) // uncomment to enforce specification
|
|
229
|
+
// throw FormatError("GS1 Indicator (FNC1 in first position) at illegal position");
|
|
230
|
+
result.symbology.modifier = '3';
|
|
231
|
+
result.symbology.aiFlag = AIFlag::GS1; // In Alphanumeric mode undouble doubled '%' and treat single '%' as <GS>
|
|
232
|
+
break;
|
|
233
|
+
case CodecMode::FNC1_SECOND_POSITION:
|
|
234
|
+
if (!result.empty())
|
|
235
|
+
throw FormatError("AIM Application Indicator (FNC1 in second position) at illegal position");
|
|
236
|
+
result.symbology.modifier = '5'; // As above
|
|
237
|
+
// ISO/IEC 18004:2015 7.4.8.3 AIM Application Indicator (FNC1 in second position), "00-99" or "A-Za-z"
|
|
238
|
+
if (int appInd = bits.readBits(8); appInd < 100) // "00-09"
|
|
239
|
+
result.append(ZXing::ToString(appInd, 2));
|
|
240
|
+
else if ((appInd >= 165 && appInd <= 190) || (appInd >= 197 && appInd <= 222)) // "A-Za-z"
|
|
241
|
+
result.push_back(appInd - 100);
|
|
242
|
+
else
|
|
243
|
+
throw FormatError("Invalid AIM Application Indicator");
|
|
244
|
+
result.symbology.aiFlag = AIFlag::AIM; // see also above
|
|
245
|
+
break;
|
|
246
|
+
case CodecMode::STRUCTURED_APPEND:
|
|
247
|
+
// sequence number and parity is added later to the result metadata
|
|
248
|
+
// Read next 4 bits of index, 4 bits of symbol count, and 8 bits of parity data, then continue
|
|
249
|
+
structuredAppend.index = bits.readBits(4);
|
|
250
|
+
structuredAppend.count = bits.readBits(4) + 1;
|
|
251
|
+
structuredAppend.id = std::to_string(bits.readBits(8));
|
|
252
|
+
break;
|
|
253
|
+
case CodecMode::ECI:
|
|
254
|
+
if (version.isModel1())
|
|
255
|
+
throw FormatError("QRCode Model 1 does not support ECI");
|
|
256
|
+
// Count doesn't apply to ECI
|
|
257
|
+
result.switchEncoding(ParseECIValue(bits));
|
|
258
|
+
break;
|
|
259
|
+
case CodecMode::HANZI: {
|
|
260
|
+
// First handle Hanzi mode which does not start with character count
|
|
261
|
+
// chinese mode contains a sub set indicator right after mode indicator
|
|
262
|
+
if (int subset = bits.readBits(4); subset != 1) // GB2312_SUBSET is the only supported one right now
|
|
263
|
+
throw FormatError("Unsupported HANZI subset");
|
|
264
|
+
int count = bits.readBits(CharacterCountBits(mode, version));
|
|
265
|
+
DecodeHanziSegment(bits, count, result);
|
|
266
|
+
break;
|
|
267
|
+
}
|
|
268
|
+
default: {
|
|
269
|
+
// "Normal" QR code modes:
|
|
270
|
+
// How many characters will follow, encoded in this mode?
|
|
271
|
+
int count = bits.readBits(CharacterCountBits(mode, version));
|
|
272
|
+
switch (mode) {
|
|
273
|
+
case CodecMode::NUMERIC: DecodeNumericSegment(bits, count, result); break;
|
|
274
|
+
case CodecMode::ALPHANUMERIC: DecodeAlphanumericSegment(bits, count, result); break;
|
|
275
|
+
case CodecMode::BYTE: DecodeByteSegment(bits, count, result); break;
|
|
276
|
+
case CodecMode::KANJI: DecodeKanjiSegment(bits, count, result); break;
|
|
277
|
+
default: throw FormatError("Invalid CodecMode");
|
|
278
|
+
}
|
|
279
|
+
break;
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
} catch (std::out_of_range&) { // see BitSource::readBits
|
|
284
|
+
error = FormatError("Truncated bit stream");
|
|
285
|
+
} catch (Error e) {
|
|
286
|
+
error = std::move(e);
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
return DecoderResult(std::move(result))
|
|
290
|
+
.setError(std::move(error))
|
|
291
|
+
.setEcLevel(ToString(ecLevel))
|
|
292
|
+
.setVersionNumber(version.versionNumber())
|
|
293
|
+
.setStructuredAppend(structuredAppend);
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
DecoderResult Decode(const BitMatrix& bits)
|
|
297
|
+
{
|
|
298
|
+
if (!Version::HasValidSize(bits))
|
|
299
|
+
return FormatError("Invalid symbol size");
|
|
300
|
+
|
|
301
|
+
auto formatInfo = ReadFormatInformation(bits);
|
|
302
|
+
if (!formatInfo.isValid())
|
|
303
|
+
return FormatError("Invalid format information");
|
|
304
|
+
|
|
305
|
+
const Version* pversion = ReadVersion(bits, formatInfo.type());
|
|
306
|
+
if (!pversion)
|
|
307
|
+
return FormatError("Invalid version");
|
|
308
|
+
|
|
309
|
+
const Version& version = *pversion;
|
|
310
|
+
|
|
311
|
+
// Read codewords
|
|
312
|
+
ByteArray codewords = ReadCodewords(bits, version, formatInfo);
|
|
313
|
+
if (codewords.empty())
|
|
314
|
+
return FormatError("Failed to read codewords");
|
|
315
|
+
|
|
316
|
+
// Separate into data blocks
|
|
317
|
+
std::vector<DataBlock> dataBlocks = DataBlock::GetDataBlocks(codewords, version, formatInfo.ecLevel);
|
|
318
|
+
if (dataBlocks.empty())
|
|
319
|
+
return FormatError("Failed to get data blocks");
|
|
320
|
+
|
|
321
|
+
// Count total number of data bytes
|
|
322
|
+
const auto op = [](auto totalBytes, const auto& dataBlock){ return totalBytes + dataBlock.numDataCodewords();};
|
|
323
|
+
const auto totalBytes = Reduce(dataBlocks, int{}, op);
|
|
324
|
+
ByteArray resultBytes(totalBytes);
|
|
325
|
+
auto resultIterator = resultBytes.begin();
|
|
326
|
+
double uec = 1.0;
|
|
327
|
+
|
|
328
|
+
// Error-correct and copy data blocks together into a stream of bytes
|
|
329
|
+
Error error;
|
|
330
|
+
for (auto& dataBlock : dataBlocks)
|
|
331
|
+
{
|
|
332
|
+
ByteArray& codewordBytes = dataBlock.codewords();
|
|
333
|
+
int numDataCodewords = dataBlock.numDataCodewords();
|
|
334
|
+
auto blockUEC = ReedSolomonDecode(RSField::QRCode, codewordBytes, Size(codewordBytes) - numDataCodewords);
|
|
335
|
+
|
|
336
|
+
if (!blockUEC)
|
|
337
|
+
error = ChecksumError();
|
|
338
|
+
|
|
339
|
+
uec = std::min(uec, blockUEC.value_or(0.0));
|
|
340
|
+
|
|
341
|
+
resultIterator = std::copy_n(codewordBytes.begin(), numDataCodewords, resultIterator);
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
auto versionStr = version.isRMQR() ? "R" + ToString(Version::SymbolSize(version.versionNumber(), version.type()), true)
|
|
345
|
+
: (version.isMicro() ? "M" : "") + std::to_string(version.versionNumber());
|
|
346
|
+
|
|
347
|
+
// Decode the contents of that stream of bytes
|
|
348
|
+
auto ret = DecodeBitStream(std::move(resultBytes), version, formatInfo.ecLevel)
|
|
349
|
+
.setIsMirrored(formatInfo.isMirrored)
|
|
350
|
+
.addExtra(BarcodeExtra::DataMask, formatInfo.dataMask, uint8_t(255))
|
|
351
|
+
.addExtra(BarcodeExtra::UEC, uec, -1.0)
|
|
352
|
+
.addExtra(BarcodeExtra::Version, versionStr)
|
|
353
|
+
;
|
|
354
|
+
if (error)
|
|
355
|
+
ret.setError(error);
|
|
356
|
+
return ret;
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
} // namespace ZXing::QRCode
|
|
@@ -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 QRCode {
|
|
15
|
+
|
|
16
|
+
DecoderResult Decode(const BitMatrix& bits);
|
|
17
|
+
|
|
18
|
+
} // QRCode
|
|
19
|
+
} // ZXing
|