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
24 #include "xfa/fxbarcode/datamatrix/BC_DataMatrixWriter.h"
25
CBC_DataMatrix()26 CBC_DataMatrix::CBC_DataMatrix() : CBC_CodeBase(new CBC_DataMatrixWriter) {}
27
~CBC_DataMatrix()28 CBC_DataMatrix::~CBC_DataMatrix() {}
29
Encode(const CFX_WideStringC & contents,FX_BOOL isDevice,int32_t & e)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;
35 uint8_t* data =
36 static_cast<CBC_DataMatrixWriter*>(m_pBCWriter.get())
37 ->Encode(CFX_WideString(contents), outWidth, outHeight, e);
38 BC_EXCEPTION_CHECK_ReturnValue(e, FALSE);
39 static_cast<CBC_TwoDimWriter*>(m_pBCWriter.get())
40 ->RenderResult(data, outWidth, outHeight, e);
41 FX_Free(data);
42 BC_EXCEPTION_CHECK_ReturnValue(e, FALSE);
43 return TRUE;
44 }
45
RenderDevice(CFX_RenderDevice * device,const CFX_Matrix * matrix,int32_t & e)46 FX_BOOL CBC_DataMatrix::RenderDevice(CFX_RenderDevice* device,
47 const CFX_Matrix* matrix,
48 int32_t& e) {
49 static_cast<CBC_TwoDimWriter*>(m_pBCWriter.get())
50 ->RenderDeviceResult(device, matrix);
51 return TRUE;
52 }
53
RenderBitmap(CFX_DIBitmap * & pOutBitmap,int32_t & e)54 FX_BOOL CBC_DataMatrix::RenderBitmap(CFX_DIBitmap*& pOutBitmap, int32_t& e) {
55 static_cast<CBC_TwoDimWriter*>(m_pBCWriter.get())
56 ->RenderBitmapResult(pOutBitmap, e);
57 BC_EXCEPTION_CHECK_ReturnValue(e, FALSE);
58 return TRUE;
59 }
60
GetType()61 BC_TYPE CBC_DataMatrix::GetType() {
62 return BC_DATAMATRIX;
63 }
64