Dan Sinclair | a98600a | 2016-03-21 15:15:56 -0400 | [diff] [blame] | 1 | // Copyright 2016 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 | * Copyright 2011 ZXing authors |
| 8 | * |
| 9 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 10 | * you may not use this file except in compliance with the License. |
| 11 | * You may obtain a copy of the License at |
| 12 | * |
| 13 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 14 | * |
| 15 | * Unless required by applicable law or agreed to in writing, software |
| 16 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 18 | * See the License for the specific language governing permissions and |
| 19 | * limitations under the License. |
| 20 | */ |
| 21 | |
| 22 | #include "xfa/fxbarcode/cbc_datamatrix.h" |
| 23 | |
Dan Sinclair | a98600a | 2016-03-21 15:15:56 -0400 | [diff] [blame] | 24 | #include "xfa/fxbarcode/datamatrix/BC_DataMatrixWriter.h" |
| 25 | |
dsinclair | a261534 | 2016-06-16 12:29:07 -0700 | [diff] [blame] | 26 | CBC_DataMatrix::CBC_DataMatrix() : CBC_CodeBase(new CBC_DataMatrixWriter) {} |
Dan Sinclair | a98600a | 2016-03-21 15:15:56 -0400 | [diff] [blame] | 27 | |
tsepez | 52d7856 | 2016-06-06 12:57:44 -0700 | [diff] [blame] | 28 | CBC_DataMatrix::~CBC_DataMatrix() {} |
Dan Sinclair | a98600a | 2016-03-21 15:15:56 -0400 | [diff] [blame] | 29 | |
| 30 | FX_BOOL CBC_DataMatrix::Encode(const CFX_WideStringC& contents, |
| 31 | FX_BOOL isDevice, |
| 32 | int32_t& e) { |
| 33 | int32_t outWidth = 0; |
| 34 | int32_t outHeight = 0; |
tsepez | afe9430 | 2016-05-13 17:21:31 -0700 | [diff] [blame] | 35 | uint8_t* data = |
tsepez | 52d7856 | 2016-06-06 12:57:44 -0700 | [diff] [blame] | 36 | static_cast<CBC_DataMatrixWriter*>(m_pBCWriter.get()) |
tsepez | afe9430 | 2016-05-13 17:21:31 -0700 | [diff] [blame] | 37 | ->Encode(CFX_WideString(contents), outWidth, outHeight, e); |
Dan Sinclair | a98600a | 2016-03-21 15:15:56 -0400 | [diff] [blame] | 38 | BC_EXCEPTION_CHECK_ReturnValue(e, FALSE); |
tsepez | 52d7856 | 2016-06-06 12:57:44 -0700 | [diff] [blame] | 39 | static_cast<CBC_TwoDimWriter*>(m_pBCWriter.get()) |
| 40 | ->RenderResult(data, outWidth, outHeight, e); |
Dan Sinclair | a98600a | 2016-03-21 15:15:56 -0400 | [diff] [blame] | 41 | FX_Free(data); |
| 42 | BC_EXCEPTION_CHECK_ReturnValue(e, FALSE); |
| 43 | return TRUE; |
| 44 | } |
| 45 | |
| 46 | FX_BOOL CBC_DataMatrix::RenderDevice(CFX_RenderDevice* device, |
thestig | fbe14b9 | 2016-05-02 13:31:10 -0700 | [diff] [blame] | 47 | const CFX_Matrix* matrix, |
Dan Sinclair | a98600a | 2016-03-21 15:15:56 -0400 | [diff] [blame] | 48 | int32_t& e) { |
tsepez | 52d7856 | 2016-06-06 12:57:44 -0700 | [diff] [blame] | 49 | static_cast<CBC_TwoDimWriter*>(m_pBCWriter.get()) |
| 50 | ->RenderDeviceResult(device, matrix); |
Dan Sinclair | a98600a | 2016-03-21 15:15:56 -0400 | [diff] [blame] | 51 | return TRUE; |
| 52 | } |
| 53 | |
| 54 | FX_BOOL CBC_DataMatrix::RenderBitmap(CFX_DIBitmap*& pOutBitmap, int32_t& e) { |
tsepez | 52d7856 | 2016-06-06 12:57:44 -0700 | [diff] [blame] | 55 | static_cast<CBC_TwoDimWriter*>(m_pBCWriter.get()) |
| 56 | ->RenderBitmapResult(pOutBitmap, e); |
Dan Sinclair | a98600a | 2016-03-21 15:15:56 -0400 | [diff] [blame] | 57 | BC_EXCEPTION_CHECK_ReturnValue(e, FALSE); |
| 58 | return TRUE; |
| 59 | } |
| 60 | |
weili | 29b8ad0 | 2016-06-14 18:20:04 -0700 | [diff] [blame] | 61 | BC_TYPE CBC_DataMatrix::GetType() { |
| 62 | return BC_DATAMATRIX; |
| 63 | } |