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 | |
Dan Sinclair | e778668 | 2017-03-29 15:18:41 -0400 | [diff] [blame] | 7 | #include "fxbarcode/BC_Writer.h" |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 8 | |
| 9 | CBC_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 | } |
| 19 | CBC_Writer::~CBC_Writer() {} |
tsepez | d19e912 | 2016-11-02 15:43:18 -0700 | [diff] [blame] | 20 | bool CBC_Writer::SetCharEncoding(int32_t encoding) { |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 21 | m_CharEncoding = encoding; |
tsepez | d19e912 | 2016-11-02 15:43:18 -0700 | [diff] [blame] | 22 | return true; |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 23 | } |
tsepez | d19e912 | 2016-11-02 15:43:18 -0700 | [diff] [blame] | 24 | bool CBC_Writer::SetModuleHeight(int32_t moduleHeight) { |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 25 | if (moduleHeight > 10 || moduleHeight < 1) { |
tsepez | d19e912 | 2016-11-02 15:43:18 -0700 | [diff] [blame] | 26 | return false; |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 27 | } |
| 28 | m_ModuleHeight = moduleHeight; |
tsepez | d19e912 | 2016-11-02 15:43:18 -0700 | [diff] [blame] | 29 | return true; |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 30 | } |
tsepez | d19e912 | 2016-11-02 15:43:18 -0700 | [diff] [blame] | 31 | bool CBC_Writer::SetModuleWidth(int32_t moduleWidth) { |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 32 | if (moduleWidth > 10 || moduleWidth < 1) { |
tsepez | d19e912 | 2016-11-02 15:43:18 -0700 | [diff] [blame] | 33 | return false; |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 34 | } |
| 35 | m_ModuleWidth = moduleWidth; |
tsepez | d19e912 | 2016-11-02 15:43:18 -0700 | [diff] [blame] | 36 | return true; |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 37 | } |
tsepez | d19e912 | 2016-11-02 15:43:18 -0700 | [diff] [blame] | 38 | bool CBC_Writer::SetHeight(int32_t height) { |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 39 | m_Height = height; |
tsepez | d19e912 | 2016-11-02 15:43:18 -0700 | [diff] [blame] | 40 | return true; |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 41 | } |
tsepez | d19e912 | 2016-11-02 15:43:18 -0700 | [diff] [blame] | 42 | bool CBC_Writer::SetWidth(int32_t width) { |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 43 | m_Width = width; |
tsepez | d19e912 | 2016-11-02 15:43:18 -0700 | [diff] [blame] | 44 | return true; |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 45 | } |
| 46 | void CBC_Writer::SetBackgroundColor(FX_ARGB backgroundColor) { |
| 47 | m_backgroundColor = backgroundColor; |
| 48 | } |
| 49 | void CBC_Writer::SetBarcodeColor(FX_ARGB foregroundColor) { |
| 50 | m_barColor = foregroundColor; |
| 51 | } |
Tom Sepez | f0799fe | 2017-03-28 09:31:32 -0700 | [diff] [blame] | 52 | |
| 53 | CFX_RetainPtr<CFX_DIBitmap> CBC_Writer::CreateDIBitmap(int32_t width, |
| 54 | int32_t height) { |
| 55 | auto pDIBitmap = pdfium::MakeRetain<CFX_DIBitmap>(); |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 56 | pDIBitmap->Create(width, height, m_colorSpace); |
| 57 | return pDIBitmap; |
| 58 | } |