• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 // Original code is licensed as follows:
7 /*
8  * Copyright 2011 ZXing authors
9  *
10  * Licensed under the Apache License, Version 2.0 (the "License");
11  * you may not use this file except in compliance with the License.
12  * You may obtain a copy of the License at
13  *
14  *      http://www.apache.org/licenses/LICENSE-2.0
15  *
16  * Unless required by applicable law or agreed to in writing, software
17  * distributed under the License is distributed on an "AS IS" BASIS,
18  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19  * See the License for the specific language governing permissions and
20  * limitations under the License.
21  */
22 
23 #include "fxbarcode/pdf417/BC_PDF417BarcodeRow.h"
24 
CBC_BarcodeRow(size_t width)25 CBC_BarcodeRow::CBC_BarcodeRow(size_t width)
26     : m_row(width), m_currentLocation(0) {}
27 
~CBC_BarcodeRow()28 CBC_BarcodeRow::~CBC_BarcodeRow() {}
29 
set(int32_t x,uint8_t value)30 void CBC_BarcodeRow::set(int32_t x, uint8_t value) {
31   m_row[x] = value;
32 }
33 
set(int32_t x,bool black)34 void CBC_BarcodeRow::set(int32_t x, bool black) {
35   m_row[x] = black ? 1 : 0;
36 }
37 
addBar(bool black,int32_t width)38 void CBC_BarcodeRow::addBar(bool black, int32_t width) {
39   for (int32_t ii = 0; ii < width; ii++)
40     set(m_currentLocation++, black);
41 }
42 
getRow()43 std::vector<uint8_t>& CBC_BarcodeRow::getRow() {
44   return m_row;
45 }
46 
getScaledRow(int32_t scale)47 std::vector<uint8_t>& CBC_BarcodeRow::getScaledRow(int32_t scale) {
48   m_output.resize(m_row.size() * scale);
49   for (size_t i = 0; i < m_output.size(); i++)
50     m_output[i] = m_row[i / scale];
51   return m_output;
52 }
53