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