OLD | NEW |
1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 PDFium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
6 | 6 |
7 #ifndef XFA_FXBARCODE_PDF417_BC_PDF417_H_ | 7 #ifndef XFA_FXBARCODE_PDF417_BC_PDF417_H_ |
8 #define XFA_FXBARCODE_PDF417_BC_PDF417_H_ | 8 #define XFA_FXBARCODE_PDF417_BC_PDF417_H_ |
9 | 9 |
10 #include <memory> | 10 #include <memory> |
11 | 11 |
12 #include "core/fxcrt/fx_basic.h" | 12 #include "core/fxcrt/fx_basic.h" |
13 #include "xfa/fxbarcode/pdf417/BC_PDF417Compaction.h" | 13 #include "xfa/fxbarcode/pdf417/BC_PDF417Compaction.h" |
14 | 14 |
15 class CBC_BarcodeRow; | 15 class CBC_BarcodeRow; |
16 class CBC_BarcodeMatrix; | 16 class CBC_BarcodeMatrix; |
17 | 17 |
18 class CBC_PDF417 { | 18 class CBC_PDF417 { |
19 public: | 19 public: |
20 CBC_PDF417(); | 20 CBC_PDF417(); |
21 explicit CBC_PDF417(FX_BOOL compact); | 21 explicit CBC_PDF417(bool compact); |
22 virtual ~CBC_PDF417(); | 22 virtual ~CBC_PDF417(); |
23 | 23 |
24 CBC_BarcodeMatrix* getBarcodeMatrix(); | 24 CBC_BarcodeMatrix* getBarcodeMatrix(); |
25 void generateBarcodeLogic(CFX_WideString msg, | 25 void generateBarcodeLogic(CFX_WideString msg, |
26 int32_t errorCorrectionLevel, | 26 int32_t errorCorrectionLevel, |
27 int32_t& e); | 27 int32_t& e); |
28 void setDimensions(int32_t maxCols, | 28 void setDimensions(int32_t maxCols, |
29 int32_t minCols, | 29 int32_t minCols, |
30 int32_t maxRows, | 30 int32_t maxRows, |
31 int32_t minRows); | 31 int32_t minRows); |
32 void setCompaction(Compaction compaction); | 32 void setCompaction(Compaction compaction); |
33 void setCompact(FX_BOOL compact); | 33 void setCompact(bool compact); |
34 | 34 |
35 private: | 35 private: |
36 static const int32_t START_PATTERN = 0x1fea8; | 36 static const int32_t START_PATTERN = 0x1fea8; |
37 static const int32_t STOP_PATTERN = 0x3fa29; | 37 static const int32_t STOP_PATTERN = 0x3fa29; |
38 static const int32_t CODEWORD_TABLE[][929]; | 38 static const int32_t CODEWORD_TABLE[][929]; |
39 static constexpr FX_FLOAT PREFERRED_RATIO = 3.0f; | 39 static constexpr FX_FLOAT PREFERRED_RATIO = 3.0f; |
40 static constexpr FX_FLOAT DEFAULT_MODULE_WIDTH = 0.357f; | 40 static constexpr FX_FLOAT DEFAULT_MODULE_WIDTH = 0.357f; |
41 static constexpr FX_FLOAT HEIGHT = 2.0f; | 41 static constexpr FX_FLOAT HEIGHT = 2.0f; |
42 | 42 |
43 static int32_t calculateNumberOfRows(int32_t m, int32_t k, int32_t c); | 43 static int32_t calculateNumberOfRows(int32_t m, int32_t k, int32_t c); |
44 static int32_t getNumberOfPadCodewords(int32_t m, | 44 static int32_t getNumberOfPadCodewords(int32_t m, |
45 int32_t k, | 45 int32_t k, |
46 int32_t c, | 46 int32_t c, |
47 int32_t r); | 47 int32_t r); |
48 static void encodeChar(int32_t pattern, int32_t len, CBC_BarcodeRow* logic); | 48 static void encodeChar(int32_t pattern, int32_t len, CBC_BarcodeRow* logic); |
49 void encodeLowLevel(CFX_WideString fullCodewords, | 49 void encodeLowLevel(CFX_WideString fullCodewords, |
50 int32_t c, | 50 int32_t c, |
51 int32_t r, | 51 int32_t r, |
52 int32_t errorCorrectionLevel, | 52 int32_t errorCorrectionLevel, |
53 CBC_BarcodeMatrix* logic); | 53 CBC_BarcodeMatrix* logic); |
54 CFX_Int32Array* determineDimensions(int32_t sourceCodeWords, | 54 CFX_Int32Array* determineDimensions(int32_t sourceCodeWords, |
55 int32_t errorCorrectionCodeWords, | 55 int32_t errorCorrectionCodeWords, |
56 int32_t& e); | 56 int32_t& e); |
57 | 57 |
58 std::unique_ptr<CBC_BarcodeMatrix> m_barcodeMatrix; | 58 std::unique_ptr<CBC_BarcodeMatrix> m_barcodeMatrix; |
59 FX_BOOL m_compact; | 59 bool m_compact; |
60 Compaction m_compaction; | 60 Compaction m_compaction; |
61 int32_t m_minCols; | 61 int32_t m_minCols; |
62 int32_t m_maxCols; | 62 int32_t m_maxCols; |
63 int32_t m_maxRows; | 63 int32_t m_maxRows; |
64 int32_t m_minRows; | 64 int32_t m_minRows; |
65 }; | 65 }; |
66 | 66 |
67 #endif // XFA_FXBARCODE_PDF417_BC_PDF417_H_ | 67 #endif // XFA_FXBARCODE_PDF417_BC_PDF417_H_ |
OLD | NEW |