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 FXBARCODE_PDF417_BC_PDF417_H_ 8 #define FXBARCODE_PDF417_BC_PDF417_H_ 9 10 #include <memory> 11 #include <vector> 12 13 #include "core/fxcrt/fx_string.h" 14 15 class CBC_BarcodeRow; 16 class CBC_BarcodeMatrix; 17 18 class CBC_PDF417 { 19 public: 20 CBC_PDF417(); 21 ~CBC_PDF417(); 22 23 CBC_BarcodeMatrix* getBarcodeMatrix(); 24 bool GenerateBarcodeLogic(WideStringView msg, int32_t errorCorrectionLevel); 25 void setDimensions(int32_t maxCols, 26 int32_t minCols, 27 int32_t maxRows, 28 int32_t minRows); 29 30 private: 31 static const int32_t START_PATTERN = 0x1fea8; 32 static const int32_t STOP_PATTERN = 0x3fa29; 33 static constexpr float PREFERRED_RATIO = 3.0f; 34 static constexpr float DEFAULT_MODULE_WIDTH = 0.357f; 35 static constexpr float HEIGHT = 2.0f; 36 37 static int32_t calculateNumberOfRows(int32_t m, int32_t k, int32_t c); 38 static int32_t getNumberOfPadCodewords(int32_t m, 39 int32_t k, 40 int32_t c, 41 int32_t r); 42 static void encodeChar(int32_t pattern, int32_t len, CBC_BarcodeRow* logic); 43 void encodeLowLevel(WideString fullCodewords, 44 int32_t c, 45 int32_t r, 46 int32_t errorCorrectionLevel, 47 CBC_BarcodeMatrix* logic); 48 std::vector<int32_t> determineDimensions( 49 size_t sourceCodeWords, 50 int32_t errorCorrectionCodeWords) const; 51 52 std::unique_ptr<CBC_BarcodeMatrix> m_barcodeMatrix; 53 int32_t m_minCols = 1; 54 int32_t m_maxCols = 30; 55 int32_t m_minRows = 3; 56 int32_t m_maxRows = 90; 57 }; 58 59 #endif // FXBARCODE_PDF417_BC_PDF417_H_ 60