blob: ee479e584b806a73918941bef377e0189df88bf5 [file] [log] [blame]
K. Moon832a6942022-10-31 20:11:31 +00001// Copyright 2014 The PDFium Authors
Dan Sinclair1770c022016-03-14 14:14:16 -04002// 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
Dan Sinclaire7786682017-03-29 15:18:41 -04007#ifndef FXBARCODE_BC_TWODIMWRITER_H_
8#define FXBARCODE_BC_TWODIMWRITER_H_
Dan Sinclair1770c022016-03-14 14:14:16 -04009
weilie76203d2016-08-09 13:45:03 -070010#include <memory>
11
Nicolas Pena37cc5fb2017-04-04 12:12:49 -040012#include "core/fxcrt/fx_coordinates.h"
Lei Zhang37935952024-02-16 04:39:56 +000013#include "core/fxcrt/span.h"
Dan Sinclaire7786682017-03-29 15:18:41 -040014#include "fxbarcode/BC_Writer.h"
Dan Sinclair1770c022016-03-14 14:14:16 -040015
16class CBC_CommonBitMatrix;
thestig25fa42f2016-05-25 21:39:46 -070017class CFX_RenderDevice;
Dan Sinclair1770c022016-03-14 14:14:16 -040018
19class CBC_TwoDimWriter : public CBC_Writer {
20 public:
Lei Zhang04bd91f2018-12-04 23:52:04 +000021 explicit CBC_TwoDimWriter(bool bFixedSize);
weili29b8ad02016-06-14 18:20:04 -070022 ~CBC_TwoDimWriter() override;
23
Tom Sepez8a118882019-11-20 23:54:33 +000024 bool RenderResult(pdfium::span<const uint8_t> code,
Lei Zhang176c0f82018-12-05 18:29:36 +000025 int32_t codeWidth,
26 int32_t codeHeight);
Tom Sepezc052ab02021-04-14 16:59:48 +000027 void RenderDeviceResult(CFX_RenderDevice* device, const CFX_Matrix& matrix);
Lei Zhang4c3b4aa2018-09-17 22:22:36 +000028
Lei Zhang04bd91f2018-12-04 23:52:04 +000029 int32_t error_correction_level() const { return m_iCorrectionLevel; }
Dan Sinclair1770c022016-03-14 14:14:16 -040030
31 protected:
Lei Zhang04bd91f2018-12-04 23:52:04 +000032 void set_error_correction_level(int32_t level) { m_iCorrectionLevel = level; }
Henrique Nakashimadc2bb9a2018-08-21 19:50:17 +000033
34 private:
weilie76203d2016-08-09 13:45:03 -070035 std::unique_ptr<CBC_CommonBitMatrix> m_output;
Henrique Nakashimadc2bb9a2018-08-21 19:50:17 +000036 int32_t m_multiX;
37 int32_t m_multiY;
38 int32_t m_leftPadding;
39 int32_t m_topPadding;
40 int32_t m_inputWidth;
41 int32_t m_inputHeight;
42 int32_t m_outputWidth;
43 int32_t m_outputHeight;
Lei Zhang04bd91f2018-12-04 23:52:04 +000044 int32_t m_iCorrectionLevel = 1;
45 const bool m_bFixedSize;
Dan Sinclair1770c022016-03-14 14:14:16 -040046};
47
Dan Sinclaire7786682017-03-29 15:18:41 -040048#endif // FXBARCODE_BC_TWODIMWRITER_H_