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.
Files changed (423) hide show
  1. package/README.md +34 -0
  2. package/VisionCameraZxing.podspec +48 -0
  3. package/android/CMakeLists.txt +43 -0
  4. package/android/build.gradle +150 -0
  5. package/android/fix-prefab.gradle +51 -0
  6. package/android/gradle.properties +5 -0
  7. package/android/src/main/AndroidManifest.xml +3 -0
  8. package/android/src/main/cpp/cpp-adapter.cpp +7 -0
  9. package/android/src/main/java/com/margelo/nitro/camera/zxing/VisionCameraZxingPackage.kt +21 -0
  10. package/cpp/BarcodeValueTypeClassifier.cpp +70 -0
  11. package/cpp/BarcodeValueTypeClassifier.hpp +14 -0
  12. package/cpp/FrameImageView.cpp +75 -0
  13. package/cpp/FrameImageView.hpp +34 -0
  14. package/cpp/HybridBarcode.cpp +59 -0
  15. package/cpp/HybridBarcode.hpp +26 -0
  16. package/cpp/HybridBarcodeScanner.cpp +121 -0
  17. package/cpp/HybridBarcodeScanner.hpp +26 -0
  18. package/cpp/HybridBarcodeScannerFactory.cpp +11 -0
  19. package/cpp/HybridBarcodeScannerFactory.hpp +14 -0
  20. package/cpp/ImageDownscaler.cpp +34 -0
  21. package/cpp/ImageDownscaler.hpp +21 -0
  22. package/cpp/ZXingDecoder.cpp +189 -0
  23. package/cpp/ZXingDecoder.hpp +72 -0
  24. package/cpp/zxing-core/LICENSE +202 -0
  25. package/cpp/zxing-core/README.md +156 -0
  26. package/cpp/zxing-core/core/CMakeLists.txt +784 -0
  27. package/cpp/zxing-core/core/Version.h.in +28 -0
  28. package/cpp/zxing-core/core/ZXingConfig.cmake.in +9 -0
  29. package/cpp/zxing-core/core/src/Barcode.cpp +255 -0
  30. package/cpp/zxing-core/core/src/Barcode.h +191 -0
  31. package/cpp/zxing-core/core/src/BarcodeData.h +100 -0
  32. package/cpp/zxing-core/core/src/BarcodeFormat.cpp +286 -0
  33. package/cpp/zxing-core/core/src/BarcodeFormat.h +272 -0
  34. package/cpp/zxing-core/core/src/BinaryBitmap.cpp +111 -0
  35. package/cpp/zxing-core/core/src/BinaryBitmap.h +66 -0
  36. package/cpp/zxing-core/core/src/BitArray.cpp +38 -0
  37. package/cpp/zxing-core/core/src/BitArray.h +181 -0
  38. package/cpp/zxing-core/core/src/BitMatrix.cpp +175 -0
  39. package/cpp/zxing-core/core/src/BitMatrix.h +199 -0
  40. package/cpp/zxing-core/core/src/BitMatrixCursor.h +253 -0
  41. package/cpp/zxing-core/core/src/BitMatrixIO.cpp +101 -0
  42. package/cpp/zxing-core/core/src/BitMatrixIO.h +21 -0
  43. package/cpp/zxing-core/core/src/BitSource.cpp +77 -0
  44. package/cpp/zxing-core/core/src/BitSource.h +72 -0
  45. package/cpp/zxing-core/core/src/ByteArray.h +42 -0
  46. package/cpp/zxing-core/core/src/CharacterSet.cpp +78 -0
  47. package/cpp/zxing-core/core/src/CharacterSet.h +58 -0
  48. package/cpp/zxing-core/core/src/ConcentricFinder.cpp +312 -0
  49. package/cpp/zxing-core/core/src/ConcentricFinder.h +156 -0
  50. package/cpp/zxing-core/core/src/Content.cpp +471 -0
  51. package/cpp/zxing-core/core/src/Content.h +82 -0
  52. package/cpp/zxing-core/core/src/ContentType.h +19 -0
  53. package/cpp/zxing-core/core/src/CreateBarcode.cpp +490 -0
  54. package/cpp/zxing-core/core/src/CreateBarcode.h +132 -0
  55. package/cpp/zxing-core/core/src/DecoderResult.h +92 -0
  56. package/cpp/zxing-core/core/src/DetectorResult.h +44 -0
  57. package/cpp/zxing-core/core/src/ECI.cpp +81 -0
  58. package/cpp/zxing-core/core/src/ECI.h +78 -0
  59. package/cpp/zxing-core/core/src/Error.cpp +29 -0
  60. package/cpp/zxing-core/core/src/Error.h +79 -0
  61. package/cpp/zxing-core/core/src/Flags.h +165 -0
  62. package/cpp/zxing-core/core/src/GTIN.cpp +253 -0
  63. package/cpp/zxing-core/core/src/GTIN.h +58 -0
  64. package/cpp/zxing-core/core/src/GlobalHistogramBinarizer.cpp +197 -0
  65. package/cpp/zxing-core/core/src/GlobalHistogramBinarizer.h +34 -0
  66. package/cpp/zxing-core/core/src/GridSampler.cpp +124 -0
  67. package/cpp/zxing-core/core/src/GridSampler.h +59 -0
  68. package/cpp/zxing-core/core/src/HRI.cpp +343 -0
  69. package/cpp/zxing-core/core/src/HRI.h +16 -0
  70. package/cpp/zxing-core/core/src/HybridBinarizer.cpp +315 -0
  71. package/cpp/zxing-core/core/src/HybridBinarizer.h +40 -0
  72. package/cpp/zxing-core/core/src/ImageView.h +168 -0
  73. package/cpp/zxing-core/core/src/JSON.cpp +154 -0
  74. package/cpp/zxing-core/core/src/JSON.h +66 -0
  75. package/cpp/zxing-core/core/src/LocalGrid.cpp +242 -0
  76. package/cpp/zxing-core/core/src/LocalGrid.h +91 -0
  77. package/cpp/zxing-core/core/src/LogMatrix.h +105 -0
  78. package/cpp/zxing-core/core/src/Matrix.h +125 -0
  79. package/cpp/zxing-core/core/src/MultiFormatReader.cpp +107 -0
  80. package/cpp/zxing-core/core/src/MultiFormatReader.h +34 -0
  81. package/cpp/zxing-core/core/src/MultiFormatWriter.cpp +111 -0
  82. package/cpp/zxing-core/core/src/MultiFormatWriter.h +62 -0
  83. package/cpp/zxing-core/core/src/Pattern.h +472 -0
  84. package/cpp/zxing-core/core/src/PerspectiveTransform.cpp +81 -0
  85. package/cpp/zxing-core/core/src/PerspectiveTransform.h +47 -0
  86. package/cpp/zxing-core/core/src/Point.h +185 -0
  87. package/cpp/zxing-core/core/src/Quadrilateral.h +215 -0
  88. package/cpp/zxing-core/core/src/Range.h +112 -0
  89. package/cpp/zxing-core/core/src/ReadBarcode.cpp +335 -0
  90. package/cpp/zxing-core/core/src/ReadBarcode.h +33 -0
  91. package/cpp/zxing-core/core/src/Reader.h +32 -0
  92. package/cpp/zxing-core/core/src/ReaderOptions.h +210 -0
  93. package/cpp/zxing-core/core/src/ReedSolomon.cpp +100 -0
  94. package/cpp/zxing-core/core/src/ReedSolomon.h +66 -0
  95. package/cpp/zxing-core/core/src/RegressionLine.h +161 -0
  96. package/cpp/zxing-core/core/src/ResultPoint.cpp +20 -0
  97. package/cpp/zxing-core/core/src/ResultPoint.h +35 -0
  98. package/cpp/zxing-core/core/src/StdGenerator.h +121 -0
  99. package/cpp/zxing-core/core/src/StdPrint.h +38 -0
  100. package/cpp/zxing-core/core/src/StdScope.h +55 -0
  101. package/cpp/zxing-core/core/src/StructuredAppend.h +19 -0
  102. package/cpp/zxing-core/core/src/SymbologyIdentifier.h +29 -0
  103. package/cpp/zxing-core/core/src/TextDecoder.cpp +59 -0
  104. package/cpp/zxing-core/core/src/TextDecoder.h +23 -0
  105. package/cpp/zxing-core/core/src/TextEncoder.cpp +75 -0
  106. package/cpp/zxing-core/core/src/TextEncoder.h +31 -0
  107. package/cpp/zxing-core/core/src/ThresholdBinarizer.h +58 -0
  108. package/cpp/zxing-core/core/src/TritMatrix.h +29 -0
  109. package/cpp/zxing-core/core/src/Utf.cpp +276 -0
  110. package/cpp/zxing-core/core/src/Utf.h +26 -0
  111. package/cpp/zxing-core/core/src/WhiteRectDetector.cpp +276 -0
  112. package/cpp/zxing-core/core/src/WhiteRectDetector.h +36 -0
  113. package/cpp/zxing-core/core/src/WriteBarcode.cpp +213 -0
  114. package/cpp/zxing-core/core/src/WriteBarcode.h +72 -0
  115. package/cpp/zxing-core/core/src/ZXAlgorithms.h +353 -0
  116. package/cpp/zxing-core/core/src/ZXConfig.h +17 -0
  117. package/cpp/zxing-core/core/src/ZXTestSupport.h +9 -0
  118. package/cpp/zxing-core/core/src/ZXVersion.h +14 -0
  119. package/cpp/zxing-core/core/src/ZXingC.cpp +460 -0
  120. package/cpp/zxing-core/core/src/ZXingC.h +296 -0
  121. package/cpp/zxing-core/core/src/ZXingCpp.cpp +18 -0
  122. package/cpp/zxing-core/core/src/ZXingCpp.h +76 -0
  123. package/cpp/zxing-core/core/src/ZXingQt.h +606 -0
  124. package/cpp/zxing-core/core/src/aztec/AZDecoder.cpp +376 -0
  125. package/cpp/zxing-core/core/src/aztec/AZDecoder.h +20 -0
  126. package/cpp/zxing-core/core/src/aztec/AZDetector.cpp +508 -0
  127. package/cpp/zxing-core/core/src/aztec/AZDetector.h +25 -0
  128. package/cpp/zxing-core/core/src/aztec/AZDetectorResult.h +51 -0
  129. package/cpp/zxing-core/core/src/aztec/AZEncoder.cpp +318 -0
  130. package/cpp/zxing-core/core/src/aztec/AZEncoder.h +44 -0
  131. package/cpp/zxing-core/core/src/aztec/AZEncodingState.h +40 -0
  132. package/cpp/zxing-core/core/src/aztec/AZHighLevelEncoder.cpp +377 -0
  133. package/cpp/zxing-core/core/src/aztec/AZHighLevelEncoder.h +36 -0
  134. package/cpp/zxing-core/core/src/aztec/AZReader.cpp +45 -0
  135. package/cpp/zxing-core/core/src/aztec/AZReader.h +21 -0
  136. package/cpp/zxing-core/core/src/aztec/AZToken.cpp +44 -0
  137. package/cpp/zxing-core/core/src/aztec/AZToken.h +39 -0
  138. package/cpp/zxing-core/core/src/aztec/AZWriter.cpp +38 -0
  139. package/cpp/zxing-core/core/src/aztec/AZWriter.h +55 -0
  140. package/cpp/zxing-core/core/src/datamatrix/DMBitLayout.cpp +194 -0
  141. package/cpp/zxing-core/core/src/datamatrix/DMBitLayout.h +21 -0
  142. package/cpp/zxing-core/core/src/datamatrix/DMDataBlock.cpp +63 -0
  143. package/cpp/zxing-core/core/src/datamatrix/DMDataBlock.h +41 -0
  144. package/cpp/zxing-core/core/src/datamatrix/DMDecoder.cpp +457 -0
  145. package/cpp/zxing-core/core/src/datamatrix/DMDecoder.h +19 -0
  146. package/cpp/zxing-core/core/src/datamatrix/DMDetector.cpp +1230 -0
  147. package/cpp/zxing-core/core/src/datamatrix/DMDetector.h +23 -0
  148. package/cpp/zxing-core/core/src/datamatrix/DMECEncoder.cpp +137 -0
  149. package/cpp/zxing-core/core/src/datamatrix/DMECEncoder.h +26 -0
  150. package/cpp/zxing-core/core/src/datamatrix/DMEncoderContext.h +128 -0
  151. package/cpp/zxing-core/core/src/datamatrix/DMHighLevelEncoder.cpp +919 -0
  152. package/cpp/zxing-core/core/src/datamatrix/DMHighLevelEncoder.h +29 -0
  153. package/cpp/zxing-core/core/src/datamatrix/DMReader.cpp +40 -0
  154. package/cpp/zxing-core/core/src/datamatrix/DMReader.h +21 -0
  155. package/cpp/zxing-core/core/src/datamatrix/DMSymbolInfo.cpp +141 -0
  156. package/cpp/zxing-core/core/src/datamatrix/DMSymbolInfo.h +78 -0
  157. package/cpp/zxing-core/core/src/datamatrix/DMSymbolShape.h +17 -0
  158. package/cpp/zxing-core/core/src/datamatrix/DMVersion.cpp +82 -0
  159. package/cpp/zxing-core/core/src/datamatrix/DMVersion.h +76 -0
  160. package/cpp/zxing-core/core/src/datamatrix/DMWriter.cpp +114 -0
  161. package/cpp/zxing-core/core/src/datamatrix/DMWriter.h +62 -0
  162. package/cpp/zxing-core/core/src/librscpp/README.md +65 -0
  163. package/cpp/zxing-core/core/src/librscpp/decode.h +258 -0
  164. package/cpp/zxing-core/core/src/librscpp/encode.h +124 -0
  165. package/cpp/zxing-core/core/src/librscpp/field.h +158 -0
  166. package/cpp/zxing-core/core/src/librscpp/poly.h +194 -0
  167. package/cpp/zxing-core/core/src/libzint/2of5inter.c +1 -0
  168. package/cpp/zxing-core/core/src/libzint/2of5inter_based.c +1 -0
  169. package/cpp/zxing-core/core/src/libzint/aztec.c +1 -0
  170. package/cpp/zxing-core/core/src/libzint/aztec.h +1 -0
  171. package/cpp/zxing-core/core/src/libzint/big5.h +1 -0
  172. package/cpp/zxing-core/core/src/libzint/codabar.c +1 -0
  173. package/cpp/zxing-core/core/src/libzint/code.c +1 -0
  174. package/cpp/zxing-core/core/src/libzint/code128.c +1 -0
  175. package/cpp/zxing-core/core/src/libzint/code128.h +1 -0
  176. package/cpp/zxing-core/core/src/libzint/common.c +1 -0
  177. package/cpp/zxing-core/core/src/libzint/common.h +1 -0
  178. package/cpp/zxing-core/core/src/libzint/dmatrix.c +1 -0
  179. package/cpp/zxing-core/core/src/libzint/dmatrix.h +1 -0
  180. package/cpp/zxing-core/core/src/libzint/dxfilmedge.c +1 -0
  181. package/cpp/zxing-core/core/src/libzint/eci.c +1 -0
  182. package/cpp/zxing-core/core/src/libzint/eci.h +1 -0
  183. package/cpp/zxing-core/core/src/libzint/eci_sb.h +1 -0
  184. package/cpp/zxing-core/core/src/libzint/filemem.c +1 -0
  185. package/cpp/zxing-core/core/src/libzint/filemem.h +1 -0
  186. package/cpp/zxing-core/core/src/libzint/fonts/normal_woff2.h +1 -0
  187. package/cpp/zxing-core/core/src/libzint/fonts/upcean_woff2.h +1 -0
  188. package/cpp/zxing-core/core/src/libzint/gb18030.h +1 -0
  189. package/cpp/zxing-core/core/src/libzint/gb2312.h +1 -0
  190. package/cpp/zxing-core/core/src/libzint/gbk.h +1 -0
  191. package/cpp/zxing-core/core/src/libzint/general_field.c +1 -0
  192. package/cpp/zxing-core/core/src/libzint/general_field.h +1 -0
  193. package/cpp/zxing-core/core/src/libzint/gs1.c +1 -0
  194. package/cpp/zxing-core/core/src/libzint/gs1.h +1 -0
  195. package/cpp/zxing-core/core/src/libzint/gs1_lint.h +1 -0
  196. package/cpp/zxing-core/core/src/libzint/iso3166.h +1 -0
  197. package/cpp/zxing-core/core/src/libzint/iso4217.h +1 -0
  198. package/cpp/zxing-core/core/src/libzint/ksx1001.h +1 -0
  199. package/cpp/zxing-core/core/src/libzint/large.c +1 -0
  200. package/cpp/zxing-core/core/src/libzint/large.h +1 -0
  201. package/cpp/zxing-core/core/src/libzint/library.c +1 -0
  202. package/cpp/zxing-core/core/src/libzint/maxicode.c +1 -0
  203. package/cpp/zxing-core/core/src/libzint/maxicode.h +1 -0
  204. package/cpp/zxing-core/core/src/libzint/medical.c +1 -0
  205. package/cpp/zxing-core/core/src/libzint/output.c +1 -0
  206. package/cpp/zxing-core/core/src/libzint/output.h +1 -0
  207. package/cpp/zxing-core/core/src/libzint/pdf417.c +1 -0
  208. package/cpp/zxing-core/core/src/libzint/pdf417.h +1 -0
  209. package/cpp/zxing-core/core/src/libzint/pdf417_tabs.h +1 -0
  210. package/cpp/zxing-core/core/src/libzint/qr.c +1 -0
  211. package/cpp/zxing-core/core/src/libzint/qr.h +1 -0
  212. package/cpp/zxing-core/core/src/libzint/raster.c +1 -0
  213. package/cpp/zxing-core/core/src/libzint/raster_font.h +1 -0
  214. package/cpp/zxing-core/core/src/libzint/reedsol.c +1 -0
  215. package/cpp/zxing-core/core/src/libzint/reedsol.h +1 -0
  216. package/cpp/zxing-core/core/src/libzint/reedsol_logs.h +1 -0
  217. package/cpp/zxing-core/core/src/libzint/rss.c +1 -0
  218. package/cpp/zxing-core/core/src/libzint/rss.h +1 -0
  219. package/cpp/zxing-core/core/src/libzint/sjis.h +1 -0
  220. package/cpp/zxing-core/core/src/libzint/stubs.c +137 -0
  221. package/cpp/zxing-core/core/src/libzint/svg.c +1 -0
  222. package/cpp/zxing-core/core/src/libzint/telepen.c +1 -0
  223. package/cpp/zxing-core/core/src/libzint/upcean.c +1 -0
  224. package/cpp/zxing-core/core/src/libzint/vector.c +1 -0
  225. package/cpp/zxing-core/core/src/libzint/zfiletypes.h +1 -0
  226. package/cpp/zxing-core/core/src/libzint/zint.h +1 -0
  227. package/cpp/zxing-core/core/src/libzint/zintconfig.h +1 -0
  228. package/cpp/zxing-core/core/src/libzueci/README.md +11 -0
  229. package/cpp/zxing-core/core/src/libzueci/zueci.c +1718 -0
  230. package/cpp/zxing-core/core/src/libzueci/zueci.h +179 -0
  231. package/cpp/zxing-core/core/src/libzueci/zueci_big5.h +3884 -0
  232. package/cpp/zxing-core/core/src/libzueci/zueci_common.h +31 -0
  233. package/cpp/zxing-core/core/src/libzueci/zueci_gb18030.h +264 -0
  234. package/cpp/zxing-core/core/src/libzueci/zueci_gb2312.h +2381 -0
  235. package/cpp/zxing-core/core/src/libzueci/zueci_gbk.h +4047 -0
  236. package/cpp/zxing-core/core/src/libzueci/zueci_ksx1001.h +2932 -0
  237. package/cpp/zxing-core/core/src/libzueci/zueci_sb.h +1112 -0
  238. package/cpp/zxing-core/core/src/libzueci/zueci_sjis.h +2286 -0
  239. package/cpp/zxing-core/core/src/maxicode/MCBitMatrixParser.cpp +68 -0
  240. package/cpp/zxing-core/core/src/maxicode/MCBitMatrixParser.h +30 -0
  241. package/cpp/zxing-core/core/src/maxicode/MCDecoder.cpp +329 -0
  242. package/cpp/zxing-core/core/src/maxicode/MCDecoder.h +19 -0
  243. package/cpp/zxing-core/core/src/maxicode/MCReader.cpp +65 -0
  244. package/cpp/zxing-core/core/src/maxicode/MCReader.h +21 -0
  245. package/cpp/zxing-core/core/src/oned/ODCodabarReader.cpp +102 -0
  246. package/cpp/zxing-core/core/src/oned/ODCodabarReader.h +21 -0
  247. package/cpp/zxing-core/core/src/oned/ODCodabarWriter.cpp +136 -0
  248. package/cpp/zxing-core/core/src/oned/ODCodabarWriter.h +34 -0
  249. package/cpp/zxing-core/core/src/oned/ODCode128Patterns.h +130 -0
  250. package/cpp/zxing-core/core/src/oned/ODCode128Reader.cpp +236 -0
  251. package/cpp/zxing-core/core/src/oned/ODCode128Reader.h +21 -0
  252. package/cpp/zxing-core/core/src/oned/ODCode128Writer.cpp +261 -0
  253. package/cpp/zxing-core/core/src/oned/ODCode128Writer.h +34 -0
  254. package/cpp/zxing-core/core/src/oned/ODCode39Reader.cpp +213 -0
  255. package/cpp/zxing-core/core/src/oned/ODCode39Reader.h +26 -0
  256. package/cpp/zxing-core/core/src/oned/ODCode39Writer.cpp +176 -0
  257. package/cpp/zxing-core/core/src/oned/ODCode39Writer.h +34 -0
  258. package/cpp/zxing-core/core/src/oned/ODCode93Patterns.h +80 -0
  259. package/cpp/zxing-core/core/src/oned/ODCode93Reader.cpp +112 -0
  260. package/cpp/zxing-core/core/src/oned/ODCode93Reader.h +21 -0
  261. package/cpp/zxing-core/core/src/oned/ODCode93Writer.cpp +192 -0
  262. package/cpp/zxing-core/core/src/oned/ODCode93Writer.h +32 -0
  263. package/cpp/zxing-core/core/src/oned/ODDXFilmEdgeReader.cpp +246 -0
  264. package/cpp/zxing-core/core/src/oned/ODDXFilmEdgeReader.h +26 -0
  265. package/cpp/zxing-core/core/src/oned/ODDataBarCommon.cpp +172 -0
  266. package/cpp/zxing-core/core/src/oned/ODDataBarCommon.h +204 -0
  267. package/cpp/zxing-core/core/src/oned/ODDataBarExpandedBitDecoder.cpp +253 -0
  268. package/cpp/zxing-core/core/src/oned/ODDataBarExpandedBitDecoder.h +19 -0
  269. package/cpp/zxing-core/core/src/oned/ODDataBarExpandedReader.cpp +383 -0
  270. package/cpp/zxing-core/core/src/oned/ODDataBarExpandedReader.h +25 -0
  271. package/cpp/zxing-core/core/src/oned/ODDataBarLimitedReader.cpp +163 -0
  272. package/cpp/zxing-core/core/src/oned/ODDataBarLimitedReader.h +23 -0
  273. package/cpp/zxing-core/core/src/oned/ODDataBarReader.cpp +240 -0
  274. package/cpp/zxing-core/core/src/oned/ODDataBarReader.h +25 -0
  275. package/cpp/zxing-core/core/src/oned/ODEAN13Writer.cpp +62 -0
  276. package/cpp/zxing-core/core/src/oned/ODEAN13Writer.h +34 -0
  277. package/cpp/zxing-core/core/src/oned/ODEAN8Writer.cpp +51 -0
  278. package/cpp/zxing-core/core/src/oned/ODEAN8Writer.h +34 -0
  279. package/cpp/zxing-core/core/src/oned/ODITFReader.cpp +97 -0
  280. package/cpp/zxing-core/core/src/oned/ODITFReader.h +33 -0
  281. package/cpp/zxing-core/core/src/oned/ODITFWriter.cpp +78 -0
  282. package/cpp/zxing-core/core/src/oned/ODITFWriter.h +34 -0
  283. package/cpp/zxing-core/core/src/oned/ODMultiUPCEANReader.cpp +323 -0
  284. package/cpp/zxing-core/core/src/oned/ODMultiUPCEANReader.h +32 -0
  285. package/cpp/zxing-core/core/src/oned/ODReader.cpp +259 -0
  286. package/cpp/zxing-core/core/src/oned/ODReader.h +35 -0
  287. package/cpp/zxing-core/core/src/oned/ODRowReader.h +222 -0
  288. package/cpp/zxing-core/core/src/oned/ODTelepenReader.cpp +199 -0
  289. package/cpp/zxing-core/core/src/oned/ODTelepenReader.h +25 -0
  290. package/cpp/zxing-core/core/src/oned/ODUPCAWriter.cpp +33 -0
  291. package/cpp/zxing-core/core/src/oned/ODUPCAWriter.h +34 -0
  292. package/cpp/zxing-core/core/src/oned/ODUPCEANCommon.cpp +80 -0
  293. package/cpp/zxing-core/core/src/oned/ODUPCEANCommon.h +129 -0
  294. package/cpp/zxing-core/core/src/oned/ODUPCEWriter.cpp +56 -0
  295. package/cpp/zxing-core/core/src/oned/ODUPCEWriter.h +34 -0
  296. package/cpp/zxing-core/core/src/oned/ODWriterHelper.cpp +39 -0
  297. package/cpp/zxing-core/core/src/oned/ODWriterHelper.h +48 -0
  298. package/cpp/zxing-core/core/src/pdf417/MicroPDFReader.cpp +796 -0
  299. package/cpp/zxing-core/core/src/pdf417/MicroPDFReader.h +23 -0
  300. package/cpp/zxing-core/core/src/pdf417/PDF417.cpp +85 -0
  301. package/cpp/zxing-core/core/src/pdf417/PDF417.h +81 -0
  302. package/cpp/zxing-core/core/src/pdf417/PDFBarcodeMetadata.h +53 -0
  303. package/cpp/zxing-core/core/src/pdf417/PDFBarcodeValue.cpp +48 -0
  304. package/cpp/zxing-core/core/src/pdf417/PDFBarcodeValue.h +38 -0
  305. package/cpp/zxing-core/core/src/pdf417/PDFBoundingBox.cpp +116 -0
  306. package/cpp/zxing-core/core/src/pdf417/PDFBoundingBox.h +75 -0
  307. package/cpp/zxing-core/core/src/pdf417/PDFCodeword.h +71 -0
  308. package/cpp/zxing-core/core/src/pdf417/PDFCodewordDecoder.cpp +588 -0
  309. package/cpp/zxing-core/core/src/pdf417/PDFCodewordDecoder.h +41 -0
  310. package/cpp/zxing-core/core/src/pdf417/PDFCompaction.h +20 -0
  311. package/cpp/zxing-core/core/src/pdf417/PDFCustomData.h +32 -0
  312. package/cpp/zxing-core/core/src/pdf417/PDFDecoder.cpp +725 -0
  313. package/cpp/zxing-core/core/src/pdf417/PDFDecoder.h +20 -0
  314. package/cpp/zxing-core/core/src/pdf417/PDFDetectionResult.cpp +247 -0
  315. package/cpp/zxing-core/core/src/pdf417/PDFDetectionResult.h +74 -0
  316. package/cpp/zxing-core/core/src/pdf417/PDFDetectionResultColumn.cpp +321 -0
  317. package/cpp/zxing-core/core/src/pdf417/PDFDetectionResultColumn.h +83 -0
  318. package/cpp/zxing-core/core/src/pdf417/PDFDetector.cpp +371 -0
  319. package/cpp/zxing-core/core/src/pdf417/PDFDetector.h +45 -0
  320. package/cpp/zxing-core/core/src/pdf417/PDFEncoder.cpp +570 -0
  321. package/cpp/zxing-core/core/src/pdf417/PDFEncoder.h +182 -0
  322. package/cpp/zxing-core/core/src/pdf417/PDFHighLevelEncoder.cpp +570 -0
  323. package/cpp/zxing-core/core/src/pdf417/PDFHighLevelEncoder.h +32 -0
  324. package/cpp/zxing-core/core/src/pdf417/PDFReader.cpp +333 -0
  325. package/cpp/zxing-core/core/src/pdf417/PDFReader.h +28 -0
  326. package/cpp/zxing-core/core/src/pdf417/PDFScanningDecoder.cpp +559 -0
  327. package/cpp/zxing-core/core/src/pdf417/PDFScanningDecoder.h +41 -0
  328. package/cpp/zxing-core/core/src/pdf417/PDFWriter.cpp +170 -0
  329. package/cpp/zxing-core/core/src/pdf417/PDFWriter.h +74 -0
  330. package/cpp/zxing-core/core/src/pdf417/ZXBigInteger.cpp +623 -0
  331. package/cpp/zxing-core/core/src/pdf417/ZXBigInteger.h +81 -0
  332. package/cpp/zxing-core/core/src/pdf417/ZXNullable.h +105 -0
  333. package/cpp/zxing-core/core/src/qrcode/QRBitMatrixParser.cpp +294 -0
  334. package/cpp/zxing-core/core/src/qrcode/QRBitMatrixParser.h +41 -0
  335. package/cpp/zxing-core/core/src/qrcode/QRCodecMode.cpp +95 -0
  336. package/cpp/zxing-core/core/src/qrcode/QRCodecMode.h +59 -0
  337. package/cpp/zxing-core/core/src/qrcode/QRDataBlock.cpp +93 -0
  338. package/cpp/zxing-core/core/src/qrcode/QRDataBlock.h +52 -0
  339. package/cpp/zxing-core/core/src/qrcode/QRDataMask.h +50 -0
  340. package/cpp/zxing-core/core/src/qrcode/QRDecoder.cpp +359 -0
  341. package/cpp/zxing-core/core/src/qrcode/QRDecoder.h +19 -0
  342. package/cpp/zxing-core/core/src/qrcode/QRDetector.cpp +920 -0
  343. package/cpp/zxing-core/core/src/qrcode/QRDetector.h +45 -0
  344. package/cpp/zxing-core/core/src/qrcode/QRECB.h +52 -0
  345. package/cpp/zxing-core/core/src/qrcode/QREncodeResult.h +33 -0
  346. package/cpp/zxing-core/core/src/qrcode/QREncoder.cpp +568 -0
  347. package/cpp/zxing-core/core/src/qrcode/QREncoder.h +21 -0
  348. package/cpp/zxing-core/core/src/qrcode/QRErrorCorrectionLevel.cpp +51 -0
  349. package/cpp/zxing-core/core/src/qrcode/QRErrorCorrectionLevel.h +39 -0
  350. package/cpp/zxing-core/core/src/qrcode/QRFormatInformation.cpp +160 -0
  351. package/cpp/zxing-core/core/src/qrcode/QRFormatInformation.h +61 -0
  352. package/cpp/zxing-core/core/src/qrcode/QRMaskUtil.cpp +156 -0
  353. package/cpp/zxing-core/core/src/qrcode/QRMaskUtil.h +15 -0
  354. package/cpp/zxing-core/core/src/qrcode/QRMatrixUtil.cpp +318 -0
  355. package/cpp/zxing-core/core/src/qrcode/QRMatrixUtil.h +25 -0
  356. package/cpp/zxing-core/core/src/qrcode/QRReader.cpp +149 -0
  357. package/cpp/zxing-core/core/src/qrcode/QRReader.h +21 -0
  358. package/cpp/zxing-core/core/src/qrcode/QRVersion.cpp +754 -0
  359. package/cpp/zxing-core/core/src/qrcode/QRVersion.h +127 -0
  360. package/cpp/zxing-core/core/src/qrcode/QRWriter.cpp +51 -0
  361. package/cpp/zxing-core/core/src/qrcode/QRWriter.h +74 -0
  362. package/cpp/zxing-core/core/version.rc.in +34 -0
  363. package/cpp/zxing-core/core/zxing.pc.in +8 -0
  364. package/cpp/zxing-core/wrappers/ios/README.md +25 -0
  365. package/cpp/zxing-core/wrappers/ios/Sources/Wrapper/Version.h +29 -0
  366. package/cpp/zxing-core/zxing-cpp.podspec +45 -0
  367. package/lib/factory.d.ts +10 -0
  368. package/lib/factory.js +12 -0
  369. package/lib/index.d.ts +9 -0
  370. package/lib/index.js +9 -0
  371. package/lib/specs/Barcode.nitro.d.ts +63 -0
  372. package/lib/specs/Barcode.nitro.js +1 -0
  373. package/lib/specs/BarcodeFormat.d.ts +11 -0
  374. package/lib/specs/BarcodeFormat.js +1 -0
  375. package/lib/specs/BarcodeScanner.nitro.d.ts +89 -0
  376. package/lib/specs/BarcodeScanner.nitro.js +1 -0
  377. package/lib/specs/BarcodeScannerFactory.nitro.d.ts +26 -0
  378. package/lib/specs/BarcodeScannerFactory.nitro.js +1 -0
  379. package/lib/specs/BarcodeValueType.d.ts +9 -0
  380. package/lib/specs/BarcodeValueType.js +1 -0
  381. package/lib/specs/Point.d.ts +14 -0
  382. package/lib/specs/Point.js +1 -0
  383. package/lib/specs/Rect.d.ts +22 -0
  384. package/lib/specs/Rect.js +1 -0
  385. package/lib/useBarcodeScanner.d.ts +23 -0
  386. package/lib/useBarcodeScanner.js +25 -0
  387. package/nitro.json +20 -0
  388. package/nitrogen/generated/.gitattributes +1 -0
  389. package/nitrogen/generated/android/VisionCameraZxing+autolinking.cmake +83 -0
  390. package/nitrogen/generated/android/VisionCameraZxing+autolinking.gradle +27 -0
  391. package/nitrogen/generated/android/VisionCameraZxingOnLoad.cpp +49 -0
  392. package/nitrogen/generated/android/VisionCameraZxingOnLoad.hpp +34 -0
  393. package/nitrogen/generated/android/kotlin/com/margelo/nitro/camera/zxing/VisionCameraZxingOnLoad.kt +35 -0
  394. package/nitrogen/generated/ios/VisionCameraZxing+autolinking.rb +62 -0
  395. package/nitrogen/generated/ios/VisionCameraZxing-Swift-Cxx-Bridge.cpp +17 -0
  396. package/nitrogen/generated/ios/VisionCameraZxing-Swift-Cxx-Bridge.hpp +27 -0
  397. package/nitrogen/generated/ios/VisionCameraZxing-Swift-Cxx-Umbrella.hpp +38 -0
  398. package/nitrogen/generated/ios/VisionCameraZxingAutolinking.mm +35 -0
  399. package/nitrogen/generated/ios/VisionCameraZxingAutolinking.swift +16 -0
  400. package/nitrogen/generated/shared/c++/BarcodeFormat.hpp +124 -0
  401. package/nitrogen/generated/shared/c++/BarcodeScannerOptions.hpp +85 -0
  402. package/nitrogen/generated/shared/c++/BarcodeValueType.hpp +120 -0
  403. package/nitrogen/generated/shared/c++/HybridBarcodeScannerSpec.cpp +23 -0
  404. package/nitrogen/generated/shared/c++/HybridBarcodeScannerSpec.hpp +74 -0
  405. package/nitrogen/generated/shared/c++/HybridBarcodeSpec.cpp +27 -0
  406. package/nitrogen/generated/shared/c++/HybridBarcodeSpec.hpp +82 -0
  407. package/nitrogen/generated/shared/c++/HybridZXingBarcodeScannerFactorySpec.cpp +21 -0
  408. package/nitrogen/generated/shared/c++/HybridZXingBarcodeScannerFactorySpec.hpp +67 -0
  409. package/nitrogen/generated/shared/c++/Point.hpp +87 -0
  410. package/nitrogen/generated/shared/c++/Rect.hpp +95 -0
  411. package/nitrogen/generated/shared/c++/TargetBarcodeFormat.hpp +124 -0
  412. package/package.json +108 -0
  413. package/react-native.config.js +16 -0
  414. package/src/factory.ts +26 -0
  415. package/src/index.ts +9 -0
  416. package/src/specs/Barcode.nitro.ts +70 -0
  417. package/src/specs/BarcodeFormat.ts +31 -0
  418. package/src/specs/BarcodeScanner.nitro.ts +91 -0
  419. package/src/specs/BarcodeScannerFactory.nitro.ts +27 -0
  420. package/src/specs/BarcodeValueType.ts +25 -0
  421. package/src/specs/Point.ts +14 -0
  422. package/src/specs/Rect.ts +22 -0
  423. package/src/useBarcodeScanner.ts +36 -0
@@ -0,0 +1,21 @@
1
+ /*
2
+ * Copyright 2016 Huy Cuong Nguyen
3
+ * Copyright 2016 ZXing authors
4
+ */
5
+ // SPDX-License-Identifier: Apache-2.0
6
+
7
+ #pragma once
8
+
9
+ #include "CharacterSet.h"
10
+
11
+ #include <string>
12
+
13
+ namespace ZXing::QRCode {
14
+
15
+ enum class ErrorCorrectionLevel;
16
+ class EncodeResult;
17
+
18
+ EncodeResult Encode(const std::wstring& content, ErrorCorrectionLevel ecLevel, CharacterSet charset, int versionNumber,
19
+ bool useGs1Format, int maskPattern = -1);
20
+
21
+ } // namespace ZXing::QRCode
@@ -0,0 +1,51 @@
1
+ /*
2
+ * Copyright 2016 Nu-book Inc.
3
+ * Copyright 2016 ZXing authors
4
+ */
5
+ // SPDX-License-Identifier: Apache-2.0
6
+
7
+ #include "QRErrorCorrectionLevel.h"
8
+
9
+ #include <cassert>
10
+
11
+ namespace ZXing::QRCode {
12
+
13
+ const char* ToString(ErrorCorrectionLevel l)
14
+ {
15
+ assert(l != ErrorCorrectionLevel::Invalid);
16
+ static const char* const LEVEL_STR[] = {"L", "M", "Q", "H", nullptr};
17
+ return LEVEL_STR[static_cast<int>(l)];
18
+ }
19
+
20
+ ErrorCorrectionLevel ECLevelFromString(const char* str)
21
+ {
22
+ switch (str[0]) {
23
+ case 'L': return ErrorCorrectionLevel::Low;
24
+ case 'M': return ErrorCorrectionLevel::Medium;
25
+ case 'Q': return ErrorCorrectionLevel::Quality;
26
+ case 'H': return ErrorCorrectionLevel::High;
27
+ default: return ErrorCorrectionLevel::Invalid;
28
+ }
29
+ }
30
+
31
+ ErrorCorrectionLevel ECLevelFromBits(int bits, const bool isMicro)
32
+ {
33
+ if (isMicro) {
34
+ constexpr ErrorCorrectionLevel LEVEL_FOR_BITS[] = {
35
+ ErrorCorrectionLevel::Low, ErrorCorrectionLevel::Low, ErrorCorrectionLevel::Medium, ErrorCorrectionLevel::Low,
36
+ ErrorCorrectionLevel::Medium, ErrorCorrectionLevel::Low, ErrorCorrectionLevel::Medium, ErrorCorrectionLevel::Quality};
37
+ return LEVEL_FOR_BITS[bits & 0x07];
38
+ }
39
+ constexpr ErrorCorrectionLevel LEVEL_FOR_BITS[] = {ErrorCorrectionLevel::Medium, ErrorCorrectionLevel::Low,
40
+ ErrorCorrectionLevel::High, ErrorCorrectionLevel::Quality};
41
+ return LEVEL_FOR_BITS[bits & 0x3];
42
+ }
43
+
44
+ int BitsFromECLevel(ErrorCorrectionLevel l)
45
+ {
46
+ assert(l != ErrorCorrectionLevel::Invalid);
47
+ static const int BITS[] = {1, 0, 3, 2, -1};
48
+ return BITS[(int)l];
49
+ }
50
+
51
+ } // namespace ZXing::QRCode
@@ -0,0 +1,39 @@
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::QRCode {
10
+
11
+ /**
12
+ * <p>See ISO 18004:2006, 6.5.1. This enum encapsulates the four error correction levels
13
+ * defined by the QR code standard.</p>
14
+ *
15
+ * @author Sean Owen
16
+ */
17
+ enum class ErrorCorrectionLevel
18
+ {
19
+ Low, // L = ~7 % correction
20
+ Medium, // M = ~15% correction
21
+ Quality, // Q = ~25% correction
22
+ High, // H = ~30% correction
23
+ Invalid, // denotes in invalid/unknown value
24
+ };
25
+
26
+ const char* ToString(ErrorCorrectionLevel l);
27
+ ErrorCorrectionLevel ECLevelFromString(const char* str);
28
+ ErrorCorrectionLevel ECLevelFromBits(int bits, bool isMicro = false);
29
+ int BitsFromECLevel(ErrorCorrectionLevel l);
30
+
31
+ enum class Type
32
+ {
33
+ Model1,
34
+ Model2,
35
+ Micro,
36
+ rMQR,
37
+ };
38
+
39
+ } // namespace ZXing::QRCode
@@ -0,0 +1,160 @@
1
+ /*
2
+ * Copyright 2016 Nu-book Inc.
3
+ * Copyright 2016 ZXing authors
4
+ * Copyright 2023 Axel Waggershauser
5
+ * Copyright 2023 gitlost
6
+ */
7
+ // SPDX-License-Identifier: Apache-2.0
8
+
9
+ #include "QRFormatInformation.h"
10
+
11
+ #include "ZXAlgorithms.h"
12
+
13
+ #include <bit>
14
+
15
+ namespace ZXing::QRCode {
16
+
17
+ static uint32_t MirrorBits(uint32_t bits)
18
+ {
19
+ return ReverseBits32(bits) >> 17;
20
+ }
21
+
22
+ static FormatInformation FindBestFormatInfo(const std::vector<uint32_t>& masks, const std::vector<uint32_t>& bits)
23
+ {
24
+ // See ISO 18004:2015, Annex C, Table C.1
25
+ constexpr uint32_t MODEL2_MASKED_PATTERNS[] = {
26
+ 0x5412, 0x5125, 0x5E7C, 0x5B4B, 0x45F9, 0x40CE, 0x4F97, 0x4AA0, 0x77C4, 0x72F3, 0x7DAA, 0x789D, 0x662F, 0x6318, 0x6C41, 0x6976,
27
+ 0x1689, 0x13BE, 0x1CE7, 0x19D0, 0x0762, 0x0255, 0x0D0C, 0x083B, 0x355F, 0x3068, 0x3F31, 0x3A06, 0x24B4, 0x2183, 0x2EDA, 0x2BED,
28
+ };
29
+
30
+ FormatInformation fi;
31
+
32
+ for (auto mask : masks)
33
+ for (int bitsIndex = 0; bitsIndex < Size(bits); ++bitsIndex)
34
+ for (uint32_t pattern : MODEL2_MASKED_PATTERNS) {
35
+ // 'unmask' the pattern first to get the original 5-data bits + 10-ec bits back
36
+ pattern ^= FORMAT_INFO_MASK_MODEL2;
37
+ // Find the pattern with fewest bits differing
38
+ if (int hammingDist = std::popcount((bits[bitsIndex] ^ mask) ^ pattern);
39
+ hammingDist < fi.hammingDistance) {
40
+ fi.mask = mask; // store the used mask to discriminate between types/models
41
+ fi.data = pattern >> 10; // drop the 10 BCH error correction bits
42
+ fi.hammingDistance = hammingDist;
43
+ fi.bitsIndex = bitsIndex;
44
+ }
45
+ }
46
+
47
+ return fi;
48
+ }
49
+
50
+ static FormatInformation FindBestFormatInfoRMQR(const std::vector<uint32_t>& bits, const std::vector<uint32_t>& subbits)
51
+ {
52
+ // See ISO/IEC 23941:2022, Annex C, Table C.1 - Valid format information sequences
53
+ constexpr uint32_t MASKED_PATTERNS[64] = { // Finder pattern side
54
+ 0x1FAB2, 0x1E597, 0x1DBDD, 0x1C4F8, 0x1B86C, 0x1A749, 0x19903, 0x18626,
55
+ 0x17F0E, 0x1602B, 0x15E61, 0x14144, 0x13DD0, 0x122F5, 0x11CBF, 0x1039A,
56
+ 0x0F1CA, 0x0EEEF, 0x0D0A5, 0x0CF80, 0x0B314, 0x0AC31, 0x0927B, 0x08D5E,
57
+ 0x07476, 0x06B53, 0x05519, 0x04A3C, 0x036A8, 0x0298D, 0x017C7, 0x008E2,
58
+ 0x3F367, 0x3EC42, 0x3D208, 0x3CD2D, 0x3B1B9, 0x3AE9C, 0x390D6, 0x38FF3,
59
+ 0x376DB, 0x369FE, 0x357B4, 0x34891, 0x33405, 0x32B20, 0x3156A, 0x30A4F,
60
+ 0x2F81F, 0x2E73A, 0x2D970, 0x2C655, 0x2BAC1, 0x2A5E4, 0x29BAE, 0x2848B,
61
+ 0x27DA3, 0x26286, 0x25CCC, 0x243E9, 0x23F7D, 0x22058, 0x21E12, 0x20137,
62
+ };
63
+ constexpr uint32_t MASKED_PATTERNS_SUB[64] = { // Finder sub pattern side
64
+ 0x20A7B, 0x2155E, 0x22B14, 0x23431, 0x248A5, 0x25780, 0x269CA, 0x276EF,
65
+ 0x28FC7, 0x290E2, 0x2AEA8, 0x2B18D, 0x2CD19, 0x2D23C, 0x2EC76, 0x2F353,
66
+ 0x30103, 0x31E26, 0x3206C, 0x33F49, 0x343DD, 0x35CF8, 0x362B2, 0x37D97,
67
+ 0x384BF, 0x39B9A, 0x3A5D0, 0x3BAF5, 0x3C661, 0x3D944, 0x3E70E, 0x3F82B,
68
+ 0x003AE, 0x01C8B, 0x022C1, 0x03DE4, 0x04170, 0x05E55, 0x0601F, 0x07F3A,
69
+ 0x08612, 0x09937, 0x0A77D, 0x0B858, 0x0C4CC, 0x0DBE9, 0x0E5A3, 0x0FA86,
70
+ 0x108D6, 0x117F3, 0x129B9, 0x1369C, 0x14A08, 0x1552D, 0x16B67, 0x17442,
71
+ 0x18D6A, 0x1924F, 0x1AC05, 0x1B320, 0x1CFB4, 0x1D091, 0x1EEDB, 0x1F1FE,
72
+ };
73
+
74
+ FormatInformation fi;
75
+
76
+ auto best = [&fi](const std::vector<uint32_t>& bits, const uint32_t (&patterns)[64], uint32_t mask)
77
+ {
78
+ for (int bitsIndex = 0; bitsIndex < Size(bits); ++bitsIndex)
79
+ for (uint32_t pattern : patterns) {
80
+ // 'unmask' the pattern first to get the original 6-data bits + 12-ec bits back
81
+ pattern ^= mask;
82
+ // Find the pattern with fewest bits differing
83
+ if (int hammingDist = std::popcount((bits[bitsIndex] ^ mask) ^ pattern);
84
+ hammingDist < fi.hammingDistance) {
85
+ fi.mask = mask; // store the used mask to discriminate between types/models
86
+ fi.data = pattern >> 12; // drop the 12 BCH error correction bits
87
+ fi.hammingDistance = hammingDist;
88
+ fi.bitsIndex = bitsIndex;
89
+ }
90
+ }
91
+ };
92
+
93
+ best(bits, MASKED_PATTERNS, FORMAT_INFO_MASK_RMQR);
94
+ if (Size(subbits)) // TODO probably remove if `sampleRMQR()` done properly
95
+ best(subbits, MASKED_PATTERNS_SUB, FORMAT_INFO_MASK_RMQR_SUB);
96
+
97
+ return fi;
98
+ }
99
+
100
+ /**
101
+ * @param formatInfoBits1 format info indicator, with mask still applied
102
+ * @param formatInfoBits2 second copy of same info; both are checked at the same time to establish best match
103
+ */
104
+ FormatInformation FormatInformation::DecodeQR(uint32_t formatInfoBits1, uint32_t formatInfoBits2)
105
+ {
106
+ // marks out the 'Dark Module' for mirrored and non-mirrored case (see Figure 25 in ISO/IEC 18004:2015)
107
+ uint32_t mirroredFormatInfoBits2 = MirrorBits(((formatInfoBits2 >> 1) & 0b111111110000000) | (formatInfoBits2 & 0b1111111));
108
+ formatInfoBits2 = ((formatInfoBits2 >> 1) & 0b111111100000000) | (formatInfoBits2 & 0b11111111);
109
+ // Some (Model2) QR codes apparently do not apply the XOR mask. Try with (standard) and without (quirk) masking.
110
+ auto fi = FindBestFormatInfo({FORMAT_INFO_MASK_MODEL2, 0, FORMAT_INFO_MASK_MODEL1},
111
+ {formatInfoBits1, formatInfoBits2, MirrorBits(formatInfoBits1), mirroredFormatInfoBits2});
112
+
113
+ // Use bits 3/4 for error correction, and 0-2 for mask.
114
+ fi.ecLevel = ECLevelFromBits((fi.data >> 3) & 0x03);
115
+ fi.dataMask = static_cast<uint8_t>(fi.data & 0x07);
116
+ fi.isMirrored = fi.bitsIndex > 1;
117
+
118
+ return fi;
119
+ }
120
+
121
+ /**
122
+ * @param formatInfoBits format info indicator, with mask still applied
123
+ */
124
+ FormatInformation FormatInformation::DecodeMQR(uint32_t formatInfoBits)
125
+ {
126
+ auto fi = FindBestFormatInfo({FORMAT_INFO_MASK_MICRO}, {formatInfoBits, MirrorBits(formatInfoBits)});
127
+
128
+ constexpr uint8_t BITS_TO_VERSION[] = {1, 2, 2, 3, 3, 4, 4, 4};
129
+
130
+ // Bits 2/3/4 contain both error correction level and version, 0/1 contain mask.
131
+ fi.ecLevel = ECLevelFromBits((fi.data >> 2) & 0x07, true);
132
+ fi.dataMask = static_cast<uint8_t>(fi.data & 0x03);
133
+ fi.microVersion = BITS_TO_VERSION[(fi.data >> 2) & 0x07];
134
+ fi.isMirrored = fi.bitsIndex == 1;
135
+
136
+ return fi;
137
+ }
138
+
139
+ /**
140
+ * @param formatInfoBits1 format info indicator, with mask still applied
141
+ * @param formatInfoBits2 second copy of same info; both are checked at the same time to establish best match
142
+ */
143
+ FormatInformation FormatInformation::DecodeRMQR(uint32_t formatInfoBits1, uint32_t formatInfoBits2)
144
+ {
145
+ FormatInformation fi;
146
+ if (formatInfoBits2)
147
+ fi = FindBestFormatInfoRMQR({formatInfoBits1}, {formatInfoBits2});
148
+ else // TODO probably remove if `sampleRMQR()` done properly
149
+ fi = FindBestFormatInfoRMQR({formatInfoBits1}, {});
150
+
151
+ // Bit 6 is error correction (M/H), and bits 0-5 version.
152
+ fi.ecLevel = ECLevelFromBits(((fi.data >> 5) & 1) << 1); // Shift to match QRCode M/H
153
+ fi.dataMask = 4; // ((y / 2) + (x / 3)) % 2 == 0
154
+ fi.microVersion = (fi.data & 0x1F) + 1;
155
+ fi.isMirrored = false; // TODO: implement mirrored format bit reading
156
+
157
+ return fi;
158
+ }
159
+
160
+ } // namespace ZXing::QRCode
@@ -0,0 +1,61 @@
1
+ /*
2
+ * Copyright 2016 Nu-book Inc.
3
+ * Copyright 2016 ZXing authors
4
+ * Copyright 2023 Axel Waggershauser
5
+ */
6
+ // SPDX-License-Identifier: Apache-2.0
7
+
8
+ #pragma once
9
+
10
+ #include "QRErrorCorrectionLevel.h"
11
+
12
+ #include <cstdint>
13
+
14
+ namespace ZXing::QRCode {
15
+
16
+ static constexpr uint32_t FORMAT_INFO_MASK_MODEL2 = 0x5412;
17
+ static constexpr uint32_t FORMAT_INFO_MASK_MODEL1 = 0x2825;
18
+ static constexpr uint32_t FORMAT_INFO_MASK_MICRO = 0x4445;
19
+ static constexpr uint32_t FORMAT_INFO_MASK_RMQR = 0x1FAB2; // Finder pattern side
20
+ static constexpr uint32_t FORMAT_INFO_MASK_RMQR_SUB = 0x20A7B; // Finder sub pattern side
21
+
22
+ class FormatInformation
23
+ {
24
+ public:
25
+ uint32_t mask = 0;
26
+ uint8_t data = 255;
27
+ uint8_t hammingDistance = 255;
28
+ uint8_t bitsIndex = 255;
29
+
30
+ bool isMirrored = false;
31
+ uint8_t dataMask = 255;
32
+ uint8_t microVersion = 0;
33
+ ErrorCorrectionLevel ecLevel = ErrorCorrectionLevel::Invalid;
34
+
35
+ FormatInformation() = default;
36
+
37
+ static FormatInformation DecodeQR(uint32_t formatInfoBits1, uint32_t formatInfoBits2);
38
+ static FormatInformation DecodeMQR(uint32_t formatInfoBits);
39
+ static FormatInformation DecodeRMQR(uint32_t formatInfoBits1, uint32_t formatInfoBits2);
40
+
41
+ // Hamming distance of the 32 masked codes is 7 (64 and 8 for rMQR), by construction, so <= 3 bits differing means we found a match
42
+ bool isValid() const { return hammingDistance <= 3; }
43
+
44
+ Type type() const
45
+ {
46
+ switch (mask) {
47
+ case FORMAT_INFO_MASK_MODEL1: return Type::Model1;
48
+ case FORMAT_INFO_MASK_MICRO: return Type::Micro;
49
+ case FORMAT_INFO_MASK_RMQR: [[fallthrough]];
50
+ case FORMAT_INFO_MASK_RMQR_SUB: return Type::rMQR;
51
+ default: return Type::Model2;
52
+ }
53
+ }
54
+
55
+ bool operator==(const FormatInformation& other) const
56
+ {
57
+ return dataMask == other.dataMask && ecLevel == other.ecLevel && type() == other.type();
58
+ }
59
+ };
60
+
61
+ } // namespace ZXing::QRCode
@@ -0,0 +1,156 @@
1
+ /*
2
+ * Copyright 2016 Huy Cuong Nguyen
3
+ * Copyright 2016 ZXing authors
4
+ */
5
+ // SPDX-License-Identifier: Apache-2.0
6
+
7
+ #include "QRMaskUtil.h"
8
+
9
+ #include "ZXAlgorithms.h"
10
+
11
+ #include <algorithm>
12
+ #include <array>
13
+ #include <cassert>
14
+ #include <cstdlib>
15
+ #include <utility>
16
+
17
+ namespace ZXing::QRCode::MaskUtil {
18
+
19
+ // Penalty weights from section 6.8.2.1
20
+ static const int N1 = 3;
21
+ static const int N2 = 3;
22
+ static const int N3 = 40;
23
+ static const int N4 = 10;
24
+
25
+ /**
26
+ * Helper function for applyMaskPenaltyRule1. We need this for doing this calculation in both
27
+ * vertical and horizontal orders respectively.
28
+ */
29
+ static int ApplyMaskPenaltyRule1Internal(const TritMatrix& matrix, bool isHorizontal)
30
+ {
31
+ int penalty = 0;
32
+ int width = matrix.width();
33
+ int height = matrix.height();
34
+ int iLimit = isHorizontal ? height : width;
35
+ int jLimit = isHorizontal ? width : height;
36
+ for (int i = 0; i < iLimit; i++) {
37
+ int numSameBitCells = 0;
38
+ int prevBit = -1;
39
+ for (int j = 0; j < jLimit; j++) {
40
+ int bit = isHorizontal ? matrix.get(j, i) : matrix.get(i, j);
41
+ if (bit == prevBit) {
42
+ numSameBitCells++;
43
+ }
44
+ else {
45
+ if (numSameBitCells >= 5) {
46
+ penalty += N1 + (numSameBitCells - 5);
47
+ }
48
+ numSameBitCells = 1; // Include the cell itself.
49
+ prevBit = bit;
50
+ }
51
+ }
52
+ if (numSameBitCells >= 5) {
53
+ penalty += N1 + (numSameBitCells - 5);
54
+ }
55
+ }
56
+ return penalty;
57
+ }
58
+
59
+ /**
60
+ * Apply mask penalty rule 1 and return the penalty. Find repetitive cells with the same color and
61
+ * give penalty to them. Example: 00000 or 11111.
62
+ */
63
+ static int ApplyMaskPenaltyRule1(const TritMatrix& matrix)
64
+ {
65
+ return ApplyMaskPenaltyRule1Internal(matrix, true) + ApplyMaskPenaltyRule1Internal(matrix, false);
66
+ }
67
+
68
+ /**
69
+ * Apply mask penalty rule 2 and return the penalty. Find 2x2 blocks with the same color and give
70
+ * penalty to them. This is actually equivalent to the spec's rule, which is to find MxN blocks and give a
71
+ * penalty proportional to (M-1)x(N-1), because this is the number of 2x2 blocks inside such a block.
72
+ */
73
+ static int ApplyMaskPenaltyRule2(const TritMatrix& matrix)
74
+ {
75
+ int penalty = 0;
76
+ for (int y = 0; y < matrix.height() - 1; y++) {
77
+ for (int x = 0; x < matrix.width() - 1; x++) {
78
+ auto value = matrix.get(x, y);
79
+ if (value == matrix.get(x+1, y) && value == matrix.get(x, y+1) && value == matrix.get(x+1, y+1)) {
80
+ penalty++;
81
+ }
82
+ }
83
+ }
84
+ return N2 * penalty;
85
+ }
86
+
87
+ template <size_t N>
88
+ static bool HasPatternAt(const std::array<bool, N>& pattern, const Trit* begin, int count, int stride)
89
+ {
90
+ assert(std::abs(count) <= (int)N);
91
+ auto end = begin + count * stride;
92
+ if (count < 0)
93
+ std::swap(begin, end);
94
+ auto a = begin;
95
+ for (auto b = pattern.begin(); a < end && b != pattern.end(); a += stride, ++b)
96
+ if (*a != *b)
97
+ return false;
98
+ return true;
99
+ }
100
+
101
+ /**
102
+ * Apply mask penalty rule 3 and return the penalty. Find consecutive runs of 1:1:3:1:1:4
103
+ * starting with black, or 4:1:1:3:1:1 starting with white, and give penalty to them. If we
104
+ * find patterns like 000010111010000, we give penalty once.
105
+ */
106
+ static int ApplyMaskPenaltyRule3(const TritMatrix& matrix)
107
+ {
108
+ const std::array<bool, 4> white = {0, 0, 0, 0};
109
+ const std::array<bool, 7> finder = {1, 0, 1, 1, 1, 0, 1};
110
+ const int whiteSize = Size(white);
111
+ const int finderSize = Size(finder);
112
+
113
+ int numPenalties = 0;
114
+ int width = matrix.width();
115
+ int height = matrix.height();
116
+ for (int y = 0; y < height; y++) {
117
+ for (int x = 0; x < width; x++) {
118
+ auto i = &matrix.get(x, y);
119
+ if (x <= width - finderSize && HasPatternAt(finder, i, finderSize, 1)
120
+ && (HasPatternAt(white, i, -std::min(x, whiteSize), 1)
121
+ || HasPatternAt(white, i + finderSize, std::min(width - x - finderSize, whiteSize), 1))) {
122
+ numPenalties++;
123
+ }
124
+ if (y <= height - finderSize && HasPatternAt(finder, i, finderSize, width)
125
+ && (HasPatternAt(white, i, -std::min(y, whiteSize), width)
126
+ || HasPatternAt(white, i + finderSize * width, std::min(height - y - finderSize, whiteSize), width))) {
127
+ numPenalties++;
128
+ }
129
+ }
130
+ }
131
+ return numPenalties * N3;
132
+ }
133
+
134
+ /**
135
+ * Apply mask penalty rule 4 and return the penalty. Calculate the ratio of dark cells and give
136
+ * penalty if the ratio is far from 50%. It gives 10 penalty for 5% distance.
137
+ */
138
+ static int ApplyMaskPenaltyRule4(const TritMatrix& matrix)
139
+ {
140
+ auto numDarkCells = std::count_if(matrix.begin(), matrix.end(), [](Trit cell) { return cell; });
141
+ auto numTotalCells = matrix.size();
142
+ auto fivePercentVariances = std::abs(numDarkCells * 2 - numTotalCells) * 10 / numTotalCells;
143
+ return narrow_cast<int>(fivePercentVariances * N4);
144
+ }
145
+
146
+ // The mask penalty calculation is complicated. See Table 21 of JISX0510:2004 (p.45) for details.
147
+ // Basically it applies four rules and summate all penalties.
148
+ int CalculateMaskPenalty(const TritMatrix& matrix)
149
+ {
150
+ return MaskUtil::ApplyMaskPenaltyRule1(matrix)
151
+ + MaskUtil::ApplyMaskPenaltyRule2(matrix)
152
+ + MaskUtil::ApplyMaskPenaltyRule3(matrix)
153
+ + MaskUtil::ApplyMaskPenaltyRule4(matrix);
154
+ }
155
+
156
+ } // namespace ZXing::QRCode::MaskUtil
@@ -0,0 +1,15 @@
1
+ /*
2
+ * Copyright 2016 Huy Cuong Nguyen
3
+ * Copyright 2016 ZXing authors
4
+ */
5
+ // SPDX-License-Identifier: Apache-2.0
6
+
7
+ #pragma once
8
+
9
+ #include "TritMatrix.h"
10
+
11
+ namespace ZXing::QRCode::MaskUtil {
12
+
13
+ int CalculateMaskPenalty(const TritMatrix& matrix);
14
+
15
+ } // namespace ZXing::QRCode::MaskUtil