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,199 @@
1
+ /*
2
+ * Copyright 2026 Axel Waggershauser
3
+ */
4
+ // SPDX-License-Identifier: Apache-2.0
5
+
6
+ #include "ODTelepenReader.h"
7
+
8
+ #include "BarcodeData.h"
9
+ #include "SymbologyIdentifier.h"
10
+ #include "ZXAlgorithms.h"
11
+
12
+ #include <cstdint>
13
+ #include <ranges>
14
+
15
+ #ifndef PRINT_DEBUG
16
+ #define printf(...){}
17
+ #endif
18
+
19
+ // This code is based on the AIM Europe USS Telepen (1991) specification and ISO/IEC 15424:2025.
20
+ // See also https://advanova.co.uk/wp-content/uploads/2022/05/Barcode-Symbology-information-and-History.pdf
21
+
22
+ namespace ZXing::OneD {
23
+
24
+ static std::string DecodeNumeric(std::string_view encoded)
25
+ {
26
+ std::string decoded;
27
+ decoded.reserve(encoded.size() * 2);
28
+
29
+ for (uint8_t codeword : encoded) {
30
+ if (codeword < 16 || codeword == 127)
31
+ decoded += codeword; // control characters
32
+ else if (17 <= codeword && codeword < 27)
33
+ (decoded += ToDigit(codeword - 17)) += 'X';
34
+ else if (27 <= codeword && codeword < 127)
35
+ decoded += ToString(codeword - 27, 2);
36
+ else // (codeword == 16): 16/DLE is the "shift to alpha" codeword and can't appear twice
37
+ return {};
38
+ }
39
+
40
+ return decoded;
41
+ }
42
+
43
+ BarcodeData TelepenReader::decodePattern(int rowNumber, PatternView& next, std::unique_ptr<RowReader::DecodingState>&) const
44
+ {
45
+ constexpr int minCharCount = 1; // TODO
46
+ constexpr int minQuietZone = 5; // spec requires 10
47
+ constexpr int minCharLength = 16 / 3;
48
+ constexpr FixedPattern<12, 16> startPatterns[3] = {
49
+ {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 3}, // START 1: "Full ASCII" in AIM Spec
50
+ {1, 1, 1, 1, 1, 1, 1, 1, 3, 1, 1, 3}, // START 2: "Compressed Numeric (+ Full ASCII)" in AIM Spec
51
+ {1, 1, 1, 1, 1, 1, 3, 1, 1, 1, 1, 3} // START 3: "Full ASCII + Compressed Numeric" in AIM Spec
52
+ };
53
+ constexpr FixedPattern<6, 6> prefixPattern = {1, 1, 1, 1, 1, 1};
54
+ constexpr FixedPattern<11, 15> endPatterns[3] = {
55
+ {3, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1}, // STOP 1
56
+ {3, 1, 1, 3, 1, 1, 1, 1, 1, 1, 1}, // STOP 2
57
+ {3, 1, 1, 1, 1, 3, 1, 1, 1, 1, 1} // STOP 3
58
+ };
59
+
60
+ // Note: In the real-world there are symbols with START 1 + STOP 1 patterns that may contain "Compressed Numeric (+ Full ASCII)"
61
+ // data, see guess-work below.
62
+
63
+ #if 0 // use fast 1:1:1:1 start pattern plausibility check, then E2E check for the whole start pattern
64
+ next = FindLeftGuard<12>(next, 2 * 12 + minCharCount * minCharLength, [=](const PatternView& view, int spaceInPixel) {
65
+ // find min/max of 4 consecutive bars/spaces and make sure they are close together
66
+ auto mB = view[0], mS = view[1], MB = view[2], MS = view[3];
67
+ if (mB > MB)
68
+ std::swap(mB, MB);
69
+ if (mS > MS)
70
+ std::swap(mS, MS);
71
+ return MB <= mB * 4 / 3 + 1 && MS <= mS * 4 / 3 + 1 && MB < 2 * mS + 1 && MS < 2 * mB + 1
72
+ && IsPattern<true>(view, startPattern, spaceInPixel, minQuietZone);
73
+ });
74
+ #else
75
+ next = FindLeftGuard<true>(next, 2 * 12 + minCharCount * minCharLength, prefixPattern, minQuietZone);
76
+ #endif
77
+ if (!next.isValid())
78
+ return {};
79
+
80
+ int startChar = 1;
81
+ for (; startChar < 4; ++startChar)
82
+ if (IsPattern<true>(next, startPatterns[startChar - 1], next.spaceInFront(), minQuietZone))
83
+ break;
84
+ if (startChar == 4 || (startChar > 1 && !readNumeric))
85
+ return {};
86
+
87
+ const auto &startPattern = startPatterns[startChar - 1];
88
+ const auto &endPattern = endPatterns[startChar - 1];
89
+
90
+ int xStart = next.pixelsInFront();
91
+ next = next.subView(0, startPattern.size());
92
+
93
+ // get threshold from start pattern
94
+ auto threshold = NarrowWideThreshold(next);
95
+ if (!threshold.isValid())
96
+ return {};
97
+
98
+ next = next.subView(startPattern.size(), endPattern.size());
99
+ std::string raw;
100
+ while (next.isValid() && !IsRightGuard<true>(next, endPattern, minQuietZone)) {
101
+ BitArray ba;
102
+ bool inBlock = false;
103
+ BarAndSpace<int> wSum, wNum, nSum, nNum;
104
+ while (next.isValid() && ba.size() < 8) {
105
+ if (next[0] > threshold[0] * 3 || next[1] > threshold[1] * 3)
106
+ return {};
107
+ BarAndSpace<bool> wide = {next[0] > threshold[0], next[1] > threshold[1]};
108
+ if (!wide.bar && !wide.space) // narrow bar, narrow space
109
+ ba.appendBit(1);
110
+ else if (!wide.bar && wide.space) // narrow bar, wide space
111
+ // trailing 10 | leading 01
112
+ ba.appendBits(std::exchange(inBlock, !inBlock) ? 0b10 : 0b01, 2);
113
+ else if (wide.bar && !wide.space) // wide bar, narrow space
114
+ ba.appendBits(0b00, 2);
115
+ else if (wide.bar && wide.space) // wide bar, wide space
116
+ ba.appendBits(0b010, 3);
117
+
118
+ for (int i = 0; i < 2; ++i) {
119
+ if (next[i] > threshold[i]) {
120
+ wSum[i] += next[i];
121
+ ++wNum[i];
122
+ } else {
123
+ nSum[i] += next[i];
124
+ ++nNum[i];
125
+ }
126
+ }
127
+
128
+ next.skipPair();
129
+ }
130
+ if (ba.size() != 8 || std::ranges::count(ba, false) % 2 != 0) // even parity check
131
+ return {};
132
+ ba.reverse();
133
+ raw += ToInt<char>(ba) & 0x7f; // drop the parity bit
134
+
135
+ printf("line: %d, threshold: %2d, %2d, wSum: %2d, %2d, wNum: %d, %d, nSum: %2d, %2d, nNum: %d, %d -> %c ends at: %d\n", rowNumber,
136
+ threshold[0], threshold[1], wSum[0], wSum[1], wNum[0], wNum[1], nSum[0], nSum[1], nNum[0], nNum[1],
137
+ raw.back(), next.pixelsInFront());
138
+
139
+ for (int i = 0; i < 2; ++i)
140
+ threshold[i] = wNum[i] && nNum[i] ? ((wSum[i] + wNum[i] / 2) / wNum[i] + (nSum[i] + nNum[i] / 2) / nNum[i]) / 2
141
+ : nNum[i] ? (2 * nSum[i] + nNum[i] / 2) / nNum[i]
142
+ : threshold[i];
143
+ }
144
+
145
+ if (raw.size() < minCharCount + 1 || !IsRightGuard<true>(next, endPattern, minQuietZone))
146
+ return {};
147
+
148
+ auto txt = raw.substr(0, raw.size() - 1); // drop checksum character
149
+ auto checkSum = (127 - (Reduce(txt, 0) % 127)) % 127;
150
+ char modifier = 0;
151
+ Error error;
152
+
153
+ if (checkSum != raw.back()) {
154
+ error = Error::Checksum;
155
+ } else {
156
+ if (startChar == 1 && readNumeric) { // "Full ASCII" in AIM Spec or "Compressed Numeric (+ Full ASCII)" in "the wild"
157
+ // Apply guesswork to determine whether to treat as "Full ASCII" or "Compressed Numeric (+ Full ASCII)"
158
+ // Num+Alpha (startChar is 2) is likely if there is at most one DLE that is not the first character and there are
159
+ // non-printable ASCII characters but none that are not used in "Compressed Numeric" to encode digits.
160
+ if (!readAlpha
161
+ || (std::ranges::count(txt, '\x10') <= 1 && txt.front() != '\x10'
162
+ && std::ranges::any_of(txt, [](uint8_t c) { return c < 32; })
163
+ && std::ranges::none_of(txt, [](uint8_t c) { return c < 16; })))
164
+ startChar = 2;
165
+ }
166
+
167
+ const auto dle = IndexOf(txt, '\x10'); // DLE (== 16) is the "shift" codeword for switching between alpha and numeric modes
168
+ // see ISO/IEC 15424:2025 4.4.3
169
+ if (startChar == 1) {
170
+ modifier = '0'; // Full ASCII mode
171
+ } else if (startChar == 2 && dle != 0) {
172
+ auto num = dle == -1 ? DecodeNumeric(txt) : DecodeNumeric(txt.substr(0, dle));
173
+ auto alpha = dle == -1 ? std::string() : txt.substr(dle + 1);
174
+ if (num.empty())
175
+ error = Error::Format; // invalid numeric encoding
176
+ else
177
+ txt = num + alpha;
178
+ modifier = dle == -1 ? '1' : '2'; // Double density numeric: only (1) / followed by full ASCII (2)
179
+ } else if (startChar == 3 && dle != 0) {
180
+ auto alpha = dle == -1 ? txt : txt.substr(0, dle);
181
+ auto num = dle == -1 ? std::string() : DecodeNumeric(txt.substr(dle + 1));
182
+ if (dle != -1 && num.empty())
183
+ error = Error::Format; // invalid numeric encoding
184
+ else
185
+ txt = alpha + num;
186
+ modifier = dle == -1 ? '0' : '4'; // Full ASCII: only (0) / followed by double density numeric (4)
187
+ } else
188
+ error = Error::Format; // DLE as first character is not allowed
189
+ }
190
+
191
+ int xStop = next.pixelsTillEnd();
192
+ SymbologyIdentifier symbologyIdentifier = {'B', modifier};
193
+ auto format = modifier == '1' ? BarcodeFormat::TelepenNumeric : BarcodeFormat::TelepenAlpha;
194
+ printf("line: %d, raw: %s, txt: %s, checksum: %d\n", rowNumber, raw.c_str(), txt.c_str(), checkSum);
195
+
196
+ return LinearBarcode(format, txt, rowNumber, xStart, xStop, symbologyIdentifier, error);
197
+ }
198
+
199
+ } // namespace ZXing::OneD
@@ -0,0 +1,25 @@
1
+ /*
2
+ * Copyright 2026 Axel Waggershauser
3
+ */
4
+ // SPDX-License-Identifier: Apache-2.0
5
+
6
+ #pragma once
7
+
8
+ #include "ODRowReader.h"
9
+
10
+ namespace ZXing::OneD {
11
+
12
+ class TelepenReader : public RowReader
13
+ {
14
+ bool readAlpha, readNumeric;
15
+ public:
16
+ explicit TelepenReader(const ReaderOptions& opts)
17
+ : RowReader(opts),
18
+ readAlpha(opts.hasFormat(BarcodeFormat::TelepenAlpha)),
19
+ readNumeric(opts.hasFormat(BarcodeFormat::TelepenNumeric))
20
+ {}
21
+
22
+ BarcodeData decodePattern(int rowNumber, PatternView& next, std::unique_ptr<DecodingState>&) const override;
23
+ };
24
+
25
+ } // namespace ZXing::OneD
@@ -0,0 +1,33 @@
1
+ /*
2
+ * Copyright 2016 Huy Cuong Nguyen
3
+ * Copyright 2016 ZXing authors
4
+ */
5
+ // SPDX-License-Identifier: Apache-2.0
6
+
7
+ #include "ODUPCAWriter.h"
8
+
9
+ #include "BitMatrix.h"
10
+ #include "ODEAN13Writer.h"
11
+ #include "Utf.h"
12
+
13
+ #include <stdexcept>
14
+
15
+ namespace ZXing::OneD {
16
+
17
+ BitMatrix
18
+ UPCAWriter::encode(const std::wstring& contents, int width, int height) const
19
+ {
20
+ // Transform a UPC-A code into the equivalent EAN-13 code, and add a check digit if it is not already present.
21
+ size_t length = contents.length();
22
+ if (length != 11 && length != 12) {
23
+ throw std::invalid_argument("Requested contents should be 11 or 12 digits long");
24
+ }
25
+ return EAN13Writer().setMargin(_sidesMargin).encode(L'0' + contents, width, height);
26
+ }
27
+
28
+ BitMatrix UPCAWriter::encode(const std::string& contents, int width, int height) const
29
+ {
30
+ return encode(FromUtf8(contents), width, height);
31
+ }
32
+
33
+ } // namespace ZXing::OneD
@@ -0,0 +1,34 @@
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 <string>
10
+
11
+ namespace ZXing {
12
+
13
+ class BitMatrix;
14
+
15
+ namespace OneD {
16
+
17
+ /**
18
+ * This object renders a UPC-A code as a {@link BitMatrix}.
19
+ *
20
+ * @author qwandor@google.com (Andrew Walbran)
21
+ */
22
+ class UPCAWriter
23
+ {
24
+ public:
25
+ UPCAWriter& setMargin(int sidesMargin) { _sidesMargin = sidesMargin; return *this; }
26
+ BitMatrix encode(const std::wstring& contents, int width, int height) const;
27
+ BitMatrix encode(const std::string& contents, int width, int height) const;
28
+
29
+ private:
30
+ int _sidesMargin = -1;
31
+ };
32
+
33
+ } // OneD
34
+ } // ZXing
@@ -0,0 +1,80 @@
1
+ /*
2
+ * Copyright 2016 Huy Cuong Nguyen
3
+ * Copyright 2016 ZXing authors
4
+ */
5
+ // SPDX-License-Identifier: Apache-2.0
6
+
7
+ #include "ODUPCEANCommon.h"
8
+
9
+ namespace ZXing::OneD {
10
+
11
+ const std::array<int, 3> UPCEANCommon::START_END_PATTERN = { 1, 1, 1 };
12
+ const std::array<int, 5> UPCEANCommon::MIDDLE_PATTERN = { 1, 1, 1, 1, 1 };
13
+ const std::array<int, 6> UPCEANCommon::UPCE_END_PATTERN = { 1, 1, 1, 1, 1, 1 };
14
+
15
+ const std::array<std::array<int, 4>, 10> UPCEANCommon::L_PATTERNS = {
16
+ 3, 2, 1, 1, // 0
17
+ 2, 2, 2, 1, // 1
18
+ 2, 1, 2, 2, // 2
19
+ 1, 4, 1, 1, // 3
20
+ 1, 1, 3, 2, // 4
21
+ 1, 2, 3, 1, // 5
22
+ 1, 1, 1, 4, // 6
23
+ 1, 3, 1, 2, // 7
24
+ 1, 2, 1, 3, // 8
25
+ 3, 1, 1, 2, // 9
26
+ };
27
+
28
+ const std::array<std::array<int, 4>, 20> UPCEANCommon::L_AND_G_PATTERNS = {
29
+ 3, 2, 1, 1, // 0
30
+ 2, 2, 2, 1, // 1
31
+ 2, 1, 2, 2, // 2
32
+ 1, 4, 1, 1, // 3
33
+ 1, 1, 3, 2, // 4
34
+ 1, 2, 3, 1, // 5
35
+ 1, 1, 1, 4, // 6
36
+ 1, 3, 1, 2, // 7
37
+ 1, 2, 1, 3, // 8
38
+ 3, 1, 1, 2, // 9
39
+ // reversed
40
+ 1, 1, 2, 3, // 10
41
+ 1, 2, 2, 2, // 11
42
+ 2, 2, 1, 2, // 12
43
+ 1, 1, 4, 1, // 13
44
+ 2, 3, 1, 1, // 14
45
+ 1, 3, 2, 1, // 15
46
+ 4, 1, 1, 1, // 16
47
+ 2, 1, 3, 1, // 17
48
+ 3, 1, 2, 1, // 18
49
+ 2, 1, 1, 3, // 19
50
+ };
51
+
52
+ // For an UPC-E barcode, the final digit is represented by the parities used
53
+ // to encode the middle six digits, according to the table below.
54
+ //
55
+ // Parity of next 6 digits
56
+ // Digit 0 1 2 3 4 5
57
+ // 0 Even Even Even Odd Odd Odd
58
+ // 1 Even Even Odd Even Odd Odd
59
+ // 2 Even Even Odd Odd Even Odd
60
+ // 3 Even Even Odd Odd Odd Even
61
+ // 4 Even Odd Even Even Odd Odd
62
+ // 5 Even Odd Odd Even Even Odd
63
+ // 6 Even Odd Odd Odd Even Even
64
+ // 7 Even Odd Even Odd Even Odd
65
+ // 8 Even Odd Even Odd Odd Even
66
+ // 9 Even Odd Odd Even Odd Even
67
+ //
68
+ // The encoding is represented by the following array, which is a bit pattern
69
+ // using Odd = 0 and Even = 1. For example, 5 is represented by:
70
+ //
71
+ // Odd Even Even Odd Odd Even
72
+ // in binary:
73
+ // 0 1 1 0 0 1 == 0x19
74
+ //
75
+ const std::array<int, 20> UPCEANCommon::NUMSYS_AND_CHECK_DIGIT_PATTERNS = {
76
+ 0x38, 0x34, 0x32, 0x31, 0x2C, 0x26, 0x23, 0x2A, 0x29, 0x25,
77
+ 0x07, 0x0B, 0x0D, 0x0E, 0x13, 0x19, 0x1C, 0x15, 0x16, 0x1A,
78
+ };
79
+
80
+ } // namespace ZXing::OneD
@@ -0,0 +1,129 @@
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 "GTIN.h"
10
+
11
+ #include <array>
12
+ #include <cstddef>
13
+ #include <stdexcept>
14
+ #include <string>
15
+
16
+ namespace ZXing::OneD::UPCEANCommon {
17
+
18
+ using Digit = std::array<int, 4>;
19
+
20
+ /**
21
+ * Start/end guard pattern.
22
+ */
23
+ extern const std::array<int, 3> START_END_PATTERN;
24
+
25
+ /**
26
+ * "Odd", or "L" patterns used to encode UPC/EAN digits.
27
+ */
28
+ extern const std::array<Digit, 10> L_PATTERNS;
29
+
30
+ /**
31
+ * Pattern marking the middle of a UPC/EAN pattern, separating the two halves.
32
+ */
33
+ extern const std::array<int, 5> MIDDLE_PATTERN;
34
+
35
+ /**
36
+ * As above but also including the "even", or "G" patterns used to encode UPC/EAN digits.
37
+ */
38
+ extern const std::array<Digit, 20> L_AND_G_PATTERNS;
39
+
40
+ /**
41
+ * UPCE end guard pattern (== MIDDLE_PATTERN + single module black bar)
42
+ */
43
+ extern const std::array<int, 6> UPCE_END_PATTERN;
44
+
45
+ /**
46
+ * See {@link #L_AND_G_PATTERNS}; these values similarly represent patterns of
47
+ * even-odd parity encodings of digits that imply both the number system (0 or 1)
48
+ * used (index / 10), and the check digit (index % 10).
49
+ */
50
+ extern const std::array<int, 20> NUMSYS_AND_CHECK_DIGIT_PATTERNS;
51
+
52
+ template <size_t N, typename T>
53
+ std::array<int, N> DigitString2IntArray(const std::basic_string<T>& in, int checkDigit = -1)
54
+ {
55
+ static_assert(N == 8 || N == 13, "invalid UPC/EAN length");
56
+
57
+ if (in.size() != N && in.size() != N - 1)
58
+ throw std::invalid_argument("Invalid input string length");
59
+
60
+ std::array<int, N> out = {};
61
+ for (size_t i = 0; i < in.size(); ++i) {
62
+ out[i] = in[i] - '0';
63
+ if (out[i] < 0 || out[i] > 9)
64
+ throw std::invalid_argument("Contents must contain only digits: 0-9");
65
+ }
66
+
67
+ if (checkDigit == -1)
68
+ checkDigit = GTIN::ComputeCheckDigit(in, N == in.size());
69
+
70
+ if (in.size() == N - 1)
71
+ out.back() = checkDigit - '0';
72
+ else if (in.back() != checkDigit)
73
+ throw std::invalid_argument("Checksum error");
74
+
75
+ return out;
76
+ }
77
+
78
+ /**
79
+ * Expands a UPC-E value back into its full, equivalent UPC-A code value.
80
+ *
81
+ * @param upce UPC-E code as string of digits
82
+ * @return equivalent UPC-A code as string of digits
83
+ */
84
+ template <typename StringT>
85
+ StringT ConvertUPCEtoUPCA(const StringT& upce)
86
+ {
87
+ if (upce.length() < 7)
88
+ return upce;
89
+
90
+ auto upceChars = upce.substr(1, 6);
91
+
92
+ StringT result;
93
+ result.reserve(12);
94
+ result += upce[0];
95
+ auto lastChar = upceChars[5];
96
+ switch (lastChar) {
97
+ case '0':
98
+ case '1':
99
+ case '2':
100
+ result += upceChars.substr(0, 2);
101
+ result += lastChar;
102
+ result += StringT(4, '0');
103
+ result += upceChars.substr(2, 3);
104
+ break;
105
+ case '3':
106
+ result += upceChars.substr(0, 3);
107
+ result += StringT(5, '0');
108
+ result += upceChars.substr(3, 2);
109
+ break;
110
+ case '4':
111
+ result += upceChars.substr(0, 4);
112
+ result += StringT(5, '0');
113
+ ;
114
+ result += upceChars[4];
115
+ break;
116
+ default:
117
+ result += upceChars.substr(0, 5);
118
+ result += StringT(4, '0');
119
+ result += lastChar;
120
+ break;
121
+ }
122
+ // Only append check digit in conversion if supplied
123
+ if (upce.length() >= 8) {
124
+ result += upce[7];
125
+ }
126
+ return result;
127
+ }
128
+
129
+ } // namespace ZXing::OneD::UPCEANCommon
@@ -0,0 +1,56 @@
1
+ /*
2
+ * Copyright 2016 Huy Cuong Nguyen
3
+ * Copyright 2016 ZXing authors
4
+ */
5
+ // SPDX-License-Identifier: Apache-2.0
6
+
7
+ #include "ODUPCEWriter.h"
8
+
9
+ #include "ODUPCEANCommon.h"
10
+ #include "ODWriterHelper.h"
11
+ #include "Utf.h"
12
+
13
+ #include <stdexcept>
14
+ #include <vector>
15
+
16
+ namespace ZXing::OneD {
17
+
18
+ static const int CODE_WIDTH = 3 + // start guard
19
+ (7 * 6) + // bars
20
+ 6; // end guard
21
+
22
+ BitMatrix
23
+ UPCEWriter::encode(const std::wstring& contents, int width, int height) const
24
+ {
25
+ auto digits = UPCEANCommon::DigitString2IntArray<8>(
26
+ contents, GTIN::ComputeCheckDigit(UPCEANCommon::ConvertUPCEtoUPCA(contents), contents.size() == 8));
27
+
28
+ int firstDigit = digits[0];
29
+ if (firstDigit != 0 && firstDigit != 1) {
30
+ throw std::invalid_argument("Number system must be 0 or 1");
31
+ }
32
+
33
+ int parities = UPCEANCommon::NUMSYS_AND_CHECK_DIGIT_PATTERNS[firstDigit * 10 + digits[7]];
34
+ std::vector<bool> result(CODE_WIDTH, false);
35
+ int pos = 0;
36
+
37
+ pos += WriterHelper::AppendPattern(result, pos, UPCEANCommon::START_END_PATTERN, true);
38
+
39
+ for (int i = 1; i <= 6; i++) {
40
+ int digit = digits[i];
41
+ if ((parities >> (6 - i) & 1) == 1) {
42
+ digit += 10;
43
+ }
44
+ pos += WriterHelper::AppendPattern(result, pos, UPCEANCommon::L_AND_G_PATTERNS[digit], false);
45
+ }
46
+
47
+ WriterHelper::AppendPattern(result, pos, UPCEANCommon::UPCE_END_PATTERN, false);
48
+ return WriterHelper::RenderResult(result, width, height, _sidesMargin >= 0 ? _sidesMargin : 9);
49
+ }
50
+
51
+ BitMatrix UPCEWriter::encode(const std::string& contents, int width, int height) const
52
+ {
53
+ return encode(FromUtf8(contents), width, height);
54
+ }
55
+
56
+ } // namespace ZXing::OneD
@@ -0,0 +1,34 @@
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 <string>
10
+
11
+ namespace ZXing {
12
+
13
+ class BitMatrix;
14
+
15
+ namespace OneD {
16
+
17
+ /**
18
+ * This object renders an UPC-E code as a {@link BitMatrix}.
19
+ *
20
+ * @author 0979097955s@gmail.com (RX)
21
+ */
22
+ class UPCEWriter
23
+ {
24
+ public:
25
+ UPCEWriter& setMargin(int sidesMargin) { _sidesMargin = sidesMargin; return *this; }
26
+ BitMatrix encode(const std::wstring& contents, int width, int height) const;
27
+ BitMatrix encode(const std::string& contents, int width, int height) const;
28
+
29
+ private:
30
+ int _sidesMargin = -1;
31
+ };
32
+
33
+ } // OneD
34
+ } // ZXing
@@ -0,0 +1,39 @@
1
+ /*
2
+ * Copyright 2016 Huy Cuong Nguyen
3
+ * Copyright 2016 ZXing authors
4
+ */
5
+ // SPDX-License-Identifier: Apache-2.0
6
+
7
+ #include "ODWriterHelper.h"
8
+
9
+ #include "BitMatrix.h"
10
+
11
+ #include <algorithm>
12
+
13
+ namespace ZXing::OneD {
14
+
15
+ /**
16
+ * @return a byte array of horizontal pixels (0 = white, 1 = black)
17
+ */
18
+ BitMatrix
19
+ WriterHelper::RenderResult(const std::vector<bool>& code, int width, int height, int sidesMargin)
20
+ {
21
+ int inputWidth = Size(code);
22
+ // Add quiet zone on both sides.
23
+ int fullWidth = inputWidth + sidesMargin;
24
+ int outputWidth = std::max(width, fullWidth);
25
+ int outputHeight = std::max(1, height);
26
+
27
+ int multiple = outputWidth / fullWidth;
28
+ int leftPadding = (outputWidth - (inputWidth * multiple)) / 2;
29
+
30
+ BitMatrix result(outputWidth, outputHeight);
31
+ for (int inputX = 0, outputX = leftPadding; inputX < inputWidth; inputX++, outputX += multiple) {
32
+ if (code[inputX]) {
33
+ result.setRegion(outputX, 0, multiple, outputHeight);
34
+ }
35
+ }
36
+ return result;
37
+ }
38
+
39
+ } // namespace ZXing::OneD
@@ -0,0 +1,48 @@
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 "BitMatrix.h"
10
+
11
+ #include <cstddef>
12
+ #include <vector>
13
+
14
+ namespace ZXing::OneD {
15
+
16
+ /**
17
+ * <p>Encapsulates functionality and implementation that is common to one-dimensional barcodes.</p>
18
+ *
19
+ * @author dsbnatut@gmail.com (Kazuki Nishiura)
20
+ */
21
+ class WriterHelper
22
+ {
23
+ public:
24
+ /**
25
+ * @return a byte array of horizontal pixels (0 = white, 1 = black)
26
+ */
27
+ static BitMatrix RenderResult(const std::vector<bool>& code, int width, int height, int sidesMargin);
28
+
29
+ /**
30
+ * @param target encode black/white pattern into this array
31
+ * @param pos position to start encoding at in {@code target}
32
+ * @param pattern lengths of black/white runs to encode
33
+ * @param startColor starting color - false for white, true for black
34
+ * @return the number of elements added to target.
35
+ */
36
+ template <typename Container>
37
+ static int AppendPattern(std::vector<bool>& target, int pos, const Container& pattern, bool startColor)
38
+ {
39
+ for (auto s : pattern) {
40
+ for (int j = 0; j < s; j++)
41
+ target[pos++] = startColor;
42
+ startColor = !startColor; // flip color after each segment
43
+ }
44
+ return Reduce(pattern);
45
+ }
46
+ };
47
+
48
+ } // namespace ZXing::OneD