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,66 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2016 Nu-book Inc.
|
|
3
|
+
* Copyright 2016 ZXing authors
|
|
4
|
+
* Copyright 2021 Axel Waggershauser
|
|
5
|
+
*/
|
|
6
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
7
|
+
|
|
8
|
+
#pragma once
|
|
9
|
+
|
|
10
|
+
#include "ImageView.h"
|
|
11
|
+
|
|
12
|
+
#include <cstdint>
|
|
13
|
+
#include <memory>
|
|
14
|
+
#include <vector>
|
|
15
|
+
|
|
16
|
+
namespace ZXing {
|
|
17
|
+
|
|
18
|
+
class BitMatrix;
|
|
19
|
+
|
|
20
|
+
using PatternRow = std::vector<uint16_t>;
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* This class is the core bitmap class used by ZXing to represent 1 bit data. Reader objects
|
|
24
|
+
* accept a BinaryBitmap and attempt to decode it.
|
|
25
|
+
*/
|
|
26
|
+
class BinaryBitmap
|
|
27
|
+
{
|
|
28
|
+
struct Cache;
|
|
29
|
+
std::unique_ptr<Cache> _cache;
|
|
30
|
+
bool _inverted = false;
|
|
31
|
+
bool _closed = false;
|
|
32
|
+
|
|
33
|
+
protected:
|
|
34
|
+
const ImageView _buffer;
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Converts a 2D array of luminance data to 1 bit (true means black).
|
|
38
|
+
*
|
|
39
|
+
* @return The 2D array of bits for the image, nullptr on error.
|
|
40
|
+
*/
|
|
41
|
+
virtual std::shared_ptr<const BitMatrix> getBlackMatrix() const = 0;
|
|
42
|
+
|
|
43
|
+
BitMatrix binarize(uint8_t threshold) const;
|
|
44
|
+
|
|
45
|
+
public:
|
|
46
|
+
BinaryBitmap(const ImageView& buffer);
|
|
47
|
+
virtual ~BinaryBitmap();
|
|
48
|
+
|
|
49
|
+
int width() const { return _buffer.width(); }
|
|
50
|
+
int height() const { return _buffer.height(); }
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Converts one row of luminance data to a vector of ints denoting the widths of the bars and spaces.
|
|
54
|
+
*/
|
|
55
|
+
virtual bool getPatternRow(int row, int rotation, PatternRow& res) const = 0;
|
|
56
|
+
|
|
57
|
+
const BitMatrix* getBitMatrix(bool transposed = false) const;
|
|
58
|
+
|
|
59
|
+
void invert();
|
|
60
|
+
bool inverted() const { return _inverted; }
|
|
61
|
+
|
|
62
|
+
void close();
|
|
63
|
+
bool closed() const { return _closed; }
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
} // ZXing
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2016 Nu-book Inc.
|
|
3
|
+
* Copyright 2016 ZXing authors
|
|
4
|
+
*/
|
|
5
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
6
|
+
|
|
7
|
+
#include "BitArray.h"
|
|
8
|
+
|
|
9
|
+
#include "ByteArray.h"
|
|
10
|
+
|
|
11
|
+
#include <cstddef>
|
|
12
|
+
#include <stdexcept>
|
|
13
|
+
|
|
14
|
+
namespace ZXing {
|
|
15
|
+
|
|
16
|
+
void
|
|
17
|
+
BitArray::bitwiseXOR(const BitArray& other)
|
|
18
|
+
{
|
|
19
|
+
if (size() != other.size()) {
|
|
20
|
+
throw std::invalid_argument("BitArray::xor(): Sizes don't match");
|
|
21
|
+
}
|
|
22
|
+
for (size_t i = 0; i < _bits.size(); i++) {
|
|
23
|
+
// The last int could be incomplete (i.e. not have 32 bits in
|
|
24
|
+
// it) but there is no problem since 0 XOR 0 == 0.
|
|
25
|
+
_bits[i] ^= other._bits[i];
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
ByteArray BitArray::toBytes(int bitOffset, int numBytes) const
|
|
30
|
+
{
|
|
31
|
+
ByteArray res(numBytes == -1 ? (size() - bitOffset + 7) / 8 : numBytes);
|
|
32
|
+
for (int i = 0; i < Size(res); i++)
|
|
33
|
+
for (int j = 0; j < 8; j++)
|
|
34
|
+
AppendBit(res[i], (numBytes != -1 || bitOffset < size()) ? get(bitOffset++) : false);
|
|
35
|
+
return res;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
} // ZXing
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2016 Nu-book Inc.
|
|
3
|
+
* Copyright 2016 ZXing authors
|
|
4
|
+
* Copyright 2017 Axel Waggershauser
|
|
5
|
+
*/
|
|
6
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
7
|
+
|
|
8
|
+
#pragma once
|
|
9
|
+
|
|
10
|
+
#include "Range.h"
|
|
11
|
+
#include "ZXAlgorithms.h"
|
|
12
|
+
|
|
13
|
+
#include <algorithm>
|
|
14
|
+
#include <cassert>
|
|
15
|
+
#include <cstdint>
|
|
16
|
+
#include <stdexcept>
|
|
17
|
+
#include <type_traits>
|
|
18
|
+
#include <vector>
|
|
19
|
+
|
|
20
|
+
namespace ZXing {
|
|
21
|
+
|
|
22
|
+
class ByteArray;
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* A simple, fast array of bits.
|
|
26
|
+
*/
|
|
27
|
+
class BitArray
|
|
28
|
+
{
|
|
29
|
+
std::vector<uint8_t> _bits;
|
|
30
|
+
|
|
31
|
+
friend class BitMatrix;
|
|
32
|
+
|
|
33
|
+
// Nothing wrong to support it, just to make it explicit, instead of by mistake.
|
|
34
|
+
// Use copy() below.
|
|
35
|
+
BitArray(const BitArray &) = default;
|
|
36
|
+
|
|
37
|
+
public:
|
|
38
|
+
|
|
39
|
+
using Iterator = std::vector<uint8_t>::const_iterator;
|
|
40
|
+
|
|
41
|
+
BitArray() = default;
|
|
42
|
+
|
|
43
|
+
explicit BitArray(int size) : _bits(size, 0) {}
|
|
44
|
+
|
|
45
|
+
BitArray(BitArray&& other) noexcept = default;
|
|
46
|
+
BitArray& operator=(BitArray&& other) noexcept = default;
|
|
47
|
+
BitArray& operator=(const BitArray &) = delete;
|
|
48
|
+
|
|
49
|
+
BitArray copy() const { return *this; }
|
|
50
|
+
|
|
51
|
+
int size() const noexcept { return Size(_bits); }
|
|
52
|
+
|
|
53
|
+
int sizeInBytes() const noexcept { return (size() + 7) / 8; }
|
|
54
|
+
|
|
55
|
+
bool get(int i) const { return _bits.at(i) != 0; }
|
|
56
|
+
void set(int i, bool val) { _bits.at(i) = val; }
|
|
57
|
+
|
|
58
|
+
// If you know exactly how may bits you are going to iterate
|
|
59
|
+
// and that you access bit in sequence, iterator is faster than get().
|
|
60
|
+
// However, be extremely careful since there is no check whatsoever.
|
|
61
|
+
// (Performance is the reason for the iterator to exist in the first place.)
|
|
62
|
+
Iterator iterAt(int i) const noexcept { return {_bits.cbegin() + i}; }
|
|
63
|
+
Iterator begin() const noexcept { return _bits.cbegin(); }
|
|
64
|
+
Iterator end() const noexcept { return _bits.cend(); }
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Appends the least-significant bits, from value, in order from most-significant to
|
|
68
|
+
* least-significant. For example, appending 6 bits from 0x000001E will append the bits
|
|
69
|
+
* 0, 1, 1, 1, 1, 0 in that order.
|
|
70
|
+
*
|
|
71
|
+
* @param value {@code int} containing bits to append
|
|
72
|
+
* @param numBits bits from value to append
|
|
73
|
+
*/
|
|
74
|
+
void appendBits(int value, int numBits)
|
|
75
|
+
{
|
|
76
|
+
assert(numBits >= 1 && numBits <= 32);
|
|
77
|
+
|
|
78
|
+
for (; numBits; --numBits)
|
|
79
|
+
_bits.push_back((value >> (numBits-1)) & 1);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
void appendBits(uint32_t value, int numBits)
|
|
83
|
+
{
|
|
84
|
+
appendBits(static_cast<int>(value), numBits);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
void appendBit(bool bit) { _bits.push_back(bit); }
|
|
88
|
+
|
|
89
|
+
void appendBitArray(const BitArray& other) { _bits.insert(_bits.end(), other.begin(), other.end()); }
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Reverses all bits in the array.
|
|
93
|
+
*/
|
|
94
|
+
void reverse() { std::reverse(_bits.begin(), _bits.end()); }
|
|
95
|
+
|
|
96
|
+
void bitwiseXOR(const BitArray& other);
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* @param bitOffset first bit to extract
|
|
100
|
+
* @param numBytes how many bytes to extract (-1 == until the end, padded with '0')
|
|
101
|
+
* @return Bytes are written most-significant bit first.
|
|
102
|
+
*/
|
|
103
|
+
ByteArray toBytes(int bitOffset = 0, int numBytes = -1) const;
|
|
104
|
+
|
|
105
|
+
using Range = ZXing::Range<Iterator>;
|
|
106
|
+
Range range() const { return {begin(), end()}; }
|
|
107
|
+
|
|
108
|
+
friend bool operator==(const BitArray& a, const BitArray& b) { return a._bits == b._bits; }
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
template <typename T = int, typename = std::enable_if_t<std::is_integral_v<T>>>
|
|
112
|
+
T ToInt(const BitArray& bits, int pos = 0, int count = 8 * sizeof(T))
|
|
113
|
+
{
|
|
114
|
+
assert(0 <= count && count <= 8 * (int)sizeof(T));
|
|
115
|
+
assert(0 <= pos && pos + count <= bits.size());
|
|
116
|
+
|
|
117
|
+
count = std::min(count, bits.size());
|
|
118
|
+
int res = 0;
|
|
119
|
+
auto it = bits.iterAt(pos);
|
|
120
|
+
for (int i = 0; i < count; ++i, ++it)
|
|
121
|
+
AppendBit(res, *it);
|
|
122
|
+
|
|
123
|
+
return res;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
template <typename T = int, typename = std::enable_if_t<std::is_integral_v<T>>>
|
|
127
|
+
std::vector<T> ToInts(const BitArray& bits, int wordSize, int totalWords, int offset = 0)
|
|
128
|
+
{
|
|
129
|
+
assert(totalWords >= bits.size() / wordSize);
|
|
130
|
+
assert(wordSize <= 8 * (int)sizeof(T));
|
|
131
|
+
|
|
132
|
+
std::vector<T> res(totalWords, 0);
|
|
133
|
+
for (int i = offset; i < bits.size(); i += wordSize)
|
|
134
|
+
res[(i - offset) / wordSize] = ToInt(bits, i, wordSize);
|
|
135
|
+
|
|
136
|
+
return res;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
class BitArrayView
|
|
140
|
+
{
|
|
141
|
+
const BitArray& bits;
|
|
142
|
+
BitArray::Iterator cur;
|
|
143
|
+
|
|
144
|
+
public:
|
|
145
|
+
BitArrayView(const BitArray& bits) : bits(bits), cur(bits.begin()) {}
|
|
146
|
+
|
|
147
|
+
BitArrayView& skipBits(int n)
|
|
148
|
+
{
|
|
149
|
+
if (cur + n > bits.end())
|
|
150
|
+
throw std::out_of_range("BitArrayView::skipBits() out of range.");
|
|
151
|
+
cur += n;
|
|
152
|
+
return *this;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
int peekBits(int n) const
|
|
156
|
+
{
|
|
157
|
+
assert(n <= 32);
|
|
158
|
+
if (cur + n > bits.end())
|
|
159
|
+
throw std::out_of_range("BitArrayView::peekBits() out of range.");
|
|
160
|
+
int res = 0;
|
|
161
|
+
for (auto i = cur; n > 0; --n, i++)
|
|
162
|
+
AppendBit(res, *i);
|
|
163
|
+
return res;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
int readBits(int n)
|
|
167
|
+
{
|
|
168
|
+
int res = peekBits(n);
|
|
169
|
+
cur += n;
|
|
170
|
+
return res;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
int size() const
|
|
174
|
+
{
|
|
175
|
+
return narrow_cast<int>(bits.end() - cur);
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
explicit operator bool() const { return size(); }
|
|
179
|
+
};
|
|
180
|
+
|
|
181
|
+
} // ZXing
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2016 Nu-book Inc.
|
|
3
|
+
* Copyright 2016 ZXing authors
|
|
4
|
+
*/
|
|
5
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
6
|
+
|
|
7
|
+
#include "BitMatrix.h"
|
|
8
|
+
|
|
9
|
+
#include "Pattern.h"
|
|
10
|
+
|
|
11
|
+
#include <algorithm>
|
|
12
|
+
#include <stdexcept>
|
|
13
|
+
#include <utility>
|
|
14
|
+
|
|
15
|
+
namespace ZXing {
|
|
16
|
+
|
|
17
|
+
void
|
|
18
|
+
BitMatrix::setRegion(int left, int top, int width, int height)
|
|
19
|
+
{
|
|
20
|
+
if (top < 0 || left < 0) {
|
|
21
|
+
throw std::invalid_argument("BitMatrix::setRegion(): Left and top must be nonnegative");
|
|
22
|
+
}
|
|
23
|
+
if (height < 1 || width < 1) {
|
|
24
|
+
throw std::invalid_argument("BitMatrix::setRegion(): Height and width must be at least 1");
|
|
25
|
+
}
|
|
26
|
+
int right = left + width;
|
|
27
|
+
int bottom = top + height;
|
|
28
|
+
if (bottom > _height || right > _width) {
|
|
29
|
+
throw std::invalid_argument("BitMatrix::setRegion(): The region must fit inside the matrix");
|
|
30
|
+
}
|
|
31
|
+
for (int y = top; y < bottom; y++) {
|
|
32
|
+
auto offset = y * _width;
|
|
33
|
+
for (int x = left; x < right; x++) {
|
|
34
|
+
_bits[offset + x] = SET_V;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
void
|
|
40
|
+
BitMatrix::rotate90()
|
|
41
|
+
{
|
|
42
|
+
BitMatrix result(height(), width());
|
|
43
|
+
for (int x = 0; x < width(); ++x) {
|
|
44
|
+
for (int y = 0; y < height(); ++y) {
|
|
45
|
+
if (get(x, y)) {
|
|
46
|
+
result.set(y, width() - x - 1);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
*this = std::move(result);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
void
|
|
54
|
+
BitMatrix::rotate180()
|
|
55
|
+
{
|
|
56
|
+
std::reverse(_bits.begin(), _bits.end());
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
void
|
|
60
|
+
BitMatrix::mirror()
|
|
61
|
+
{
|
|
62
|
+
for (int x = 0; x < _width; x++) {
|
|
63
|
+
for (int y = x + 1; y < _height; y++) {
|
|
64
|
+
if (get(x, y) != get(y, x)) {
|
|
65
|
+
flip(y, x);
|
|
66
|
+
flip(x, y);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
bool
|
|
73
|
+
BitMatrix::findBoundingBox(int &left, int& top, int& width, int& height, int minSize) const
|
|
74
|
+
{
|
|
75
|
+
int right, bottom;
|
|
76
|
+
if (!getTopLeftOnBit(left, top) || !getBottomRightOnBit(right, bottom) || bottom - top + 1 < minSize)
|
|
77
|
+
return false;
|
|
78
|
+
|
|
79
|
+
for (int y = top; y <= bottom; y++ ) {
|
|
80
|
+
for (int x = 0; x < left; ++x)
|
|
81
|
+
if (get(x, y)) {
|
|
82
|
+
left = x;
|
|
83
|
+
break;
|
|
84
|
+
}
|
|
85
|
+
for (int x = _width-1; x > right; x--)
|
|
86
|
+
if (get(x, y)) {
|
|
87
|
+
right = x;
|
|
88
|
+
break;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
width = right - left + 1;
|
|
93
|
+
height = bottom - top + 1;
|
|
94
|
+
return width >= minSize && height >= minSize;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
static auto isSet = [](auto v) { return bool(v); };
|
|
98
|
+
|
|
99
|
+
bool
|
|
100
|
+
BitMatrix::getTopLeftOnBit(int& left, int& top) const
|
|
101
|
+
{
|
|
102
|
+
int bitsOffset = (int)std::distance(_bits.begin(), std::find_if(_bits.begin(), _bits.end(), isSet));
|
|
103
|
+
if (bitsOffset == Size(_bits)) {
|
|
104
|
+
return false;
|
|
105
|
+
}
|
|
106
|
+
top = bitsOffset / _width;
|
|
107
|
+
left = (bitsOffset % _width);
|
|
108
|
+
return true;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
bool
|
|
112
|
+
BitMatrix::getBottomRightOnBit(int& right, int& bottom) const
|
|
113
|
+
{
|
|
114
|
+
int bitsOffset = Size(_bits) - 1 - (int)std::distance(_bits.rbegin(), std::find_if(_bits.rbegin(), _bits.rend(), isSet));
|
|
115
|
+
if (bitsOffset < 0) {
|
|
116
|
+
return false;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
bottom = bitsOffset / _width;
|
|
120
|
+
right = (bitsOffset % _width);
|
|
121
|
+
return true;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
void GetPatternRow(const BitMatrix& matrix, int r, std::vector<uint16_t>& pr, bool transpose)
|
|
125
|
+
{
|
|
126
|
+
if (transpose)
|
|
127
|
+
GetPatternRow(matrix.col(r), pr);
|
|
128
|
+
else
|
|
129
|
+
GetPatternRow(matrix.row(r), pr);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
BitMatrix Inflate(BitMatrix&& input, int width, int height, int quietZone)
|
|
133
|
+
{
|
|
134
|
+
const int codeWidth = input.width();
|
|
135
|
+
const int codeHeight = input.height();
|
|
136
|
+
const int outputWidth = std::max(width, codeWidth + 2 * quietZone);
|
|
137
|
+
const int outputHeight = std::max(height, codeHeight + 2 * quietZone);
|
|
138
|
+
|
|
139
|
+
if (input.width() == outputWidth && input.height() == outputHeight)
|
|
140
|
+
return std::move(input);
|
|
141
|
+
|
|
142
|
+
const int scale = std::min((outputWidth - 2*quietZone) / codeWidth, (outputHeight - 2*quietZone) / codeHeight);
|
|
143
|
+
// Padding includes both the quiet zone and the extra white pixels to
|
|
144
|
+
// accommodate the requested dimensions.
|
|
145
|
+
const int leftPadding = (outputWidth - (codeWidth * scale)) / 2;
|
|
146
|
+
const int topPadding = (outputHeight - (codeHeight * scale)) / 2;
|
|
147
|
+
|
|
148
|
+
BitMatrix result(outputWidth, outputHeight);
|
|
149
|
+
|
|
150
|
+
for (int inputY = 0, outputY = topPadding; inputY < input.height(); ++inputY, outputY += scale) {
|
|
151
|
+
for (int inputX = 0, outputX = leftPadding; inputX < input.width(); ++inputX, outputX += scale) {
|
|
152
|
+
if (input.get(inputX, inputY))
|
|
153
|
+
result.setRegion(outputX, outputY, scale, scale);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
return result;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
BitMatrix Deflate(const BitMatrix& input, int width, int height, float top, float left, float subSampling)
|
|
161
|
+
{
|
|
162
|
+
BitMatrix result(width, height);
|
|
163
|
+
|
|
164
|
+
for (int y = 0; y < result.height(); y++) {
|
|
165
|
+
auto yOffset = top + y * subSampling;
|
|
166
|
+
for (int x = 0; x < result.width(); x++) {
|
|
167
|
+
if (input.get(PointF(left + x * subSampling, yOffset)))
|
|
168
|
+
result.set(x, y);
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
return result;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
} // ZXing
|
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2016 Nu-book Inc.
|
|
3
|
+
* Copyright 2016 ZXing authors
|
|
4
|
+
* Copyright 2022 Axel Waggershauser
|
|
5
|
+
*/
|
|
6
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
7
|
+
|
|
8
|
+
#pragma once
|
|
9
|
+
|
|
10
|
+
#include "Matrix.h"
|
|
11
|
+
#include "Point.h"
|
|
12
|
+
|
|
13
|
+
#ifdef ZXING_INTERNAL
|
|
14
|
+
#include "Range.h"
|
|
15
|
+
#endif
|
|
16
|
+
|
|
17
|
+
#include <cstdint>
|
|
18
|
+
#include <stdexcept>
|
|
19
|
+
#include <vector>
|
|
20
|
+
|
|
21
|
+
namespace ZXing {
|
|
22
|
+
|
|
23
|
+
class BitArray;
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* @brief A simple, fast 2D array of bits.
|
|
27
|
+
*/
|
|
28
|
+
class BitMatrix
|
|
29
|
+
{
|
|
30
|
+
int _width = 0;
|
|
31
|
+
int _height = 0;
|
|
32
|
+
using data_t = uint8_t;
|
|
33
|
+
|
|
34
|
+
std::vector<data_t> _bits;
|
|
35
|
+
// There is nothing wrong to support this but disable to make it explicit since we may copy something very big here.
|
|
36
|
+
// Use copy() below.
|
|
37
|
+
BitMatrix(const BitMatrix&) = default;
|
|
38
|
+
|
|
39
|
+
const data_t& get(int i) const
|
|
40
|
+
{
|
|
41
|
+
#if 1
|
|
42
|
+
return _bits.at(i);
|
|
43
|
+
#else
|
|
44
|
+
return _bits[i];
|
|
45
|
+
#endif
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
data_t& get(int i) { return const_cast<data_t&>(static_cast<const BitMatrix*>(this)->get(i)); }
|
|
49
|
+
|
|
50
|
+
bool getTopLeftOnBit(int &left, int& top) const;
|
|
51
|
+
bool getBottomRightOnBit(int &right, int& bottom) const;
|
|
52
|
+
|
|
53
|
+
public:
|
|
54
|
+
static constexpr data_t SET_V = 0xff; // allows playing with SIMD binarization
|
|
55
|
+
static constexpr data_t UNSET_V = 0;
|
|
56
|
+
static_assert(bool(SET_V) && !bool(UNSET_V), "SET_V needs to evaluate to true, UNSET_V to false, see iterator usage");
|
|
57
|
+
|
|
58
|
+
BitMatrix() = default;
|
|
59
|
+
|
|
60
|
+
#if defined(__llvm__) || (defined(__GNUC__) && (__GNUC__ > 7))
|
|
61
|
+
__attribute__((no_sanitize("signed-integer-overflow")))
|
|
62
|
+
#endif
|
|
63
|
+
BitMatrix(int width, int height) : _width(width), _height(height), _bits(width * height, UNSET_V)
|
|
64
|
+
{
|
|
65
|
+
if (width != 0 && int(_bits.size()) / width != height)
|
|
66
|
+
throw std::invalid_argument("Invalid size: width * height is too big");
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
explicit BitMatrix(int dimension) : BitMatrix(dimension, dimension) {} // Construct a square matrix.
|
|
70
|
+
|
|
71
|
+
BitMatrix(BitMatrix&& other) noexcept = default;
|
|
72
|
+
BitMatrix& operator=(BitMatrix&& other) noexcept = default;
|
|
73
|
+
BitMatrix& operator=(const BitMatrix&) = delete;
|
|
74
|
+
|
|
75
|
+
BitMatrix copy() const { return *this; }
|
|
76
|
+
|
|
77
|
+
#ifdef ZXING_INTERNAL
|
|
78
|
+
Range<data_t*> row(int y) { return {_bits.data() + y * _width, _bits.data() + (y + 1) * _width}; }
|
|
79
|
+
Range<const data_t*> row(int y) const { return {_bits.data() + y * _width, _bits.data() + (y + 1) * _width}; }
|
|
80
|
+
|
|
81
|
+
Range<StrideIter<const data_t*>> col(int x) const
|
|
82
|
+
{
|
|
83
|
+
return {{_bits.data() + x + (_height - 1) * _width, -_width}, {_bits.data() + x - _width, -_width}};
|
|
84
|
+
}
|
|
85
|
+
#endif
|
|
86
|
+
|
|
87
|
+
bool get(int x, int y) const { return get(y * _width + x); }
|
|
88
|
+
void set(int x, int y, bool val = true) { get(y * _width + x) = val * SET_V; }
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* <p>Flips the given bit.</p>
|
|
92
|
+
*
|
|
93
|
+
* @param x The horizontal component (i.e. which column)
|
|
94
|
+
* @param y The vertical component (i.e. which row)
|
|
95
|
+
*/
|
|
96
|
+
void flip(int x, int y)
|
|
97
|
+
{
|
|
98
|
+
auto& v = get(y * _width + x);
|
|
99
|
+
v = !v;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
void flipAll()
|
|
103
|
+
{
|
|
104
|
+
for (auto& i : _bits)
|
|
105
|
+
i = !i * SET_V;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* <p>Sets a square region of the bit matrix to true.</p>
|
|
110
|
+
*
|
|
111
|
+
* @param left The horizontal position to begin at (inclusive)
|
|
112
|
+
* @param top The vertical position to begin at (inclusive)
|
|
113
|
+
* @param width The width of the region
|
|
114
|
+
* @param height The height of the region
|
|
115
|
+
*/
|
|
116
|
+
void setRegion(int left, int top, int width, int height);
|
|
117
|
+
|
|
118
|
+
void rotate90();
|
|
119
|
+
|
|
120
|
+
void rotate180();
|
|
121
|
+
|
|
122
|
+
void mirror();
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* Find the rectangle that contains all non-white pixels. Useful for detection of 'pure' barcodes.
|
|
126
|
+
*
|
|
127
|
+
* @return True iff this rectangle is at least minWidth x minHeight pixels big
|
|
128
|
+
*/
|
|
129
|
+
bool findBoundingBox(int &left, int& top, int& width, int& height, int minSize = 1) const;
|
|
130
|
+
|
|
131
|
+
int width() const { return _width; }
|
|
132
|
+
|
|
133
|
+
int height() const { return _height; }
|
|
134
|
+
|
|
135
|
+
bool empty() const { return _bits.empty(); }
|
|
136
|
+
|
|
137
|
+
friend bool operator==(const BitMatrix& a, const BitMatrix& b)
|
|
138
|
+
{
|
|
139
|
+
return a._width == b._width && a._height == b._height && a._bits == b._bits;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
template <typename T>
|
|
143
|
+
bool isIn(PointT<T> p, int b = 0) const noexcept
|
|
144
|
+
{
|
|
145
|
+
return b <= p.x && p.x < width() - b && b <= p.y && p.y < height() - b;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
bool get(PointI p) const { return get(p.x, p.y); }
|
|
149
|
+
bool get(PointF p) const { return get(PointI(p)); }
|
|
150
|
+
void set(PointI p, bool v = true) { set(p.x, p.y, v); }
|
|
151
|
+
void set(PointF p, bool v = true) { set(PointI(p), v); }
|
|
152
|
+
};
|
|
153
|
+
|
|
154
|
+
void GetPatternRow(const BitMatrix& matrix, int r, std::vector<uint16_t>& pr, bool transpose);
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* @brief Inflate scales a BitMatrix up and adds a quiet Zone plus padding
|
|
158
|
+
* @param input matrix to be expanded
|
|
159
|
+
* @param width new width in bits (pixel)
|
|
160
|
+
* @param height new height in bits (pixel)
|
|
161
|
+
* @param quietZone size of quiet zone to add in modules
|
|
162
|
+
* @return expanded BitMatrix, maybe move(input) if size did not change
|
|
163
|
+
*/
|
|
164
|
+
BitMatrix Inflate(BitMatrix&& input, int width, int height, int quietZone);
|
|
165
|
+
|
|
166
|
+
/**
|
|
167
|
+
* @brief Deflate (crop + subsample) a bit matrix
|
|
168
|
+
* @param input matrix to be shrunk
|
|
169
|
+
* @param width new width
|
|
170
|
+
* @param height new height
|
|
171
|
+
* @param top cropping starts at top row
|
|
172
|
+
* @param left cropping starts at left col
|
|
173
|
+
* @param subSampling typically the module size
|
|
174
|
+
* @return deflated input
|
|
175
|
+
*/
|
|
176
|
+
BitMatrix Deflate(const BitMatrix& input, int width, int height, float top, float left, float subSampling);
|
|
177
|
+
|
|
178
|
+
template<typename T>
|
|
179
|
+
BitMatrix ToBitMatrix(const Matrix<T>& in, T trueValue = {true})
|
|
180
|
+
{
|
|
181
|
+
BitMatrix out(in.width(), in.height());
|
|
182
|
+
for (int y = 0; y < in.height(); ++y)
|
|
183
|
+
for (int x = 0; x < in.width(); ++x)
|
|
184
|
+
if (in.get(x, y) == trueValue)
|
|
185
|
+
out.set(x, y);
|
|
186
|
+
return out;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
template<typename T>
|
|
190
|
+
Matrix<T> ToMatrix(const BitMatrix& in, T black = 0, T white = ~0)
|
|
191
|
+
{
|
|
192
|
+
Matrix<T> res(in.width(), in.height());
|
|
193
|
+
for (int y = 0; y < in.height(); ++y)
|
|
194
|
+
for (int x = 0; x < in.width(); ++x)
|
|
195
|
+
res.set(x, y, in.get(x, y) ? black : white);
|
|
196
|
+
return res;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
} // ZXing
|