blob: 9a109bfbdd7a7ecfc9c1fa170bffd837e0fb837f [file] [log] [blame]
Dan Sinclair1770c022016-03-14 14:14:16 -04001// 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
Dan Sinclaire7786682017-03-29 15:18:41 -04007#include "fxbarcode/BC_Writer.h"
Dan Sinclair1770c022016-03-14 14:14:16 -04008
9CBC_Writer::CBC_Writer() {
10 m_CharEncoding = 0;
11 m_ModuleHeight = 1;
12 m_ModuleWidth = 1;
13 m_Height = 320;
14 m_Width = 640;
15 m_colorSpace = FXDIB_Argb;
16 m_barColor = 0xff000000;
17 m_backgroundColor = 0xffffffff;
18}
19CBC_Writer::~CBC_Writer() {}
tsepezd19e9122016-11-02 15:43:18 -070020bool CBC_Writer::SetCharEncoding(int32_t encoding) {
Dan Sinclair1770c022016-03-14 14:14:16 -040021 m_CharEncoding = encoding;
tsepezd19e9122016-11-02 15:43:18 -070022 return true;
Dan Sinclair1770c022016-03-14 14:14:16 -040023}
tsepezd19e9122016-11-02 15:43:18 -070024bool CBC_Writer::SetModuleHeight(int32_t moduleHeight) {
Dan Sinclair1770c022016-03-14 14:14:16 -040025 if (moduleHeight > 10 || moduleHeight < 1) {
tsepezd19e9122016-11-02 15:43:18 -070026 return false;
Dan Sinclair1770c022016-03-14 14:14:16 -040027 }
28 m_ModuleHeight = moduleHeight;
tsepezd19e9122016-11-02 15:43:18 -070029 return true;
Dan Sinclair1770c022016-03-14 14:14:16 -040030}
tsepezd19e9122016-11-02 15:43:18 -070031bool CBC_Writer::SetModuleWidth(int32_t moduleWidth) {
Dan Sinclair1770c022016-03-14 14:14:16 -040032 if (moduleWidth > 10 || moduleWidth < 1) {
tsepezd19e9122016-11-02 15:43:18 -070033 return false;
Dan Sinclair1770c022016-03-14 14:14:16 -040034 }
35 m_ModuleWidth = moduleWidth;
tsepezd19e9122016-11-02 15:43:18 -070036 return true;
Dan Sinclair1770c022016-03-14 14:14:16 -040037}
tsepezd19e9122016-11-02 15:43:18 -070038bool CBC_Writer::SetHeight(int32_t height) {
Dan Sinclair1770c022016-03-14 14:14:16 -040039 m_Height = height;
tsepezd19e9122016-11-02 15:43:18 -070040 return true;
Dan Sinclair1770c022016-03-14 14:14:16 -040041}
tsepezd19e9122016-11-02 15:43:18 -070042bool CBC_Writer::SetWidth(int32_t width) {
Dan Sinclair1770c022016-03-14 14:14:16 -040043 m_Width = width;
tsepezd19e9122016-11-02 15:43:18 -070044 return true;
Dan Sinclair1770c022016-03-14 14:14:16 -040045}
46void CBC_Writer::SetBackgroundColor(FX_ARGB backgroundColor) {
47 m_backgroundColor = backgroundColor;
48}
49void CBC_Writer::SetBarcodeColor(FX_ARGB foregroundColor) {
50 m_barColor = foregroundColor;
51}
Tom Sepezf0799fe2017-03-28 09:31:32 -070052
53CFX_RetainPtr<CFX_DIBitmap> CBC_Writer::CreateDIBitmap(int32_t width,
54 int32_t height) {
55 auto pDIBitmap = pdfium::MakeRetain<CFX_DIBitmap>();
Dan Sinclair1770c022016-03-14 14:14:16 -040056 pDIBitmap->Create(width, height, m_colorSpace);
57 return pDIBitmap;
58}