1 // Copyright 2014 PDFium Authors. All rights reserved.
\r
2 // Use of this source code is governed by a BSD-style license that can be
\r
3 // found in the LICENSE file.
\r
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
\r
8 #include "include/BC_PDF417Codeword.h"
\r
9 #include "include/BC_PDF417BoundingBox.h"
\r
10 #include "include/BC_PDF417DetectionResultColumn.h"
\r
11 FX_INT32 CBC_DetectionResultColumn::MAX_NEARBY_DISTANCE = 5;
\r
12 CBC_DetectionResultColumn::CBC_DetectionResultColumn(CBC_BoundingBox* boundingBox)
\r
14 m_boundingBox = boundingBox;
\r
15 m_codewords = FX_NEW CFX_PtrArray;
\r
16 m_codewords->SetSize(boundingBox->getMaxY() - boundingBox->getMinY() + 1);
\r
18 CBC_DetectionResultColumn::~CBC_DetectionResultColumn()
\r
20 for (FX_INT32 i = 0; i < m_codewords->GetSize(); i++) {
\r
21 delete (CBC_Codeword*)m_codewords->GetAt(i);
\r
23 m_codewords->RemoveAll();
\r
26 CBC_Codeword* CBC_DetectionResultColumn::getCodewordNearby(FX_INT32 imageRow)
\r
28 CBC_Codeword* codeword = getCodeword(imageRow);
\r
29 if (codeword != NULL) {
\r
32 for (FX_INT32 i = 1; i < MAX_NEARBY_DISTANCE; i++) {
\r
33 FX_INT32 nearImageRow = imageRowToCodewordIndex(imageRow) - i;
\r
34 if (nearImageRow >= 0) {
\r
35 codeword = (CBC_Codeword*)m_codewords->GetAt(nearImageRow);
\r
36 if (codeword != NULL) {
\r
40 nearImageRow = imageRowToCodewordIndex(imageRow) + i;
\r
41 if (nearImageRow < m_codewords->GetSize()) {
\r
42 codeword = (CBC_Codeword*)m_codewords->GetAt(nearImageRow);
\r
43 if (codeword != NULL) {
\r
50 FX_INT32 CBC_DetectionResultColumn::imageRowToCodewordIndex(FX_INT32 imageRow)
\r
52 return imageRow - m_boundingBox->getMinY();
\r
54 FX_INT32 CBC_DetectionResultColumn::codewordIndexToImageRow(FX_INT32 codewordIndex)
\r
56 return m_boundingBox->getMinY() + codewordIndex;
\r
58 void CBC_DetectionResultColumn::setCodeword(FX_INT32 imageRow, CBC_Codeword* codeword)
\r
60 m_codewords->SetAt(imageRowToCodewordIndex(imageRow), codeword);
\r
62 CBC_Codeword* CBC_DetectionResultColumn::getCodeword(FX_INT32 imageRow)
\r
64 return (CBC_Codeword*)m_codewords->GetAt(imageRowToCodewordIndex(imageRow));
\r
66 CBC_BoundingBox* CBC_DetectionResultColumn::getBoundingBox()
\r
68 return m_boundingBox;
\r
70 CFX_PtrArray* CBC_DetectionResultColumn::getCodewords()
\r
74 CFX_ByteString CBC_DetectionResultColumn::toString()
\r
76 CFX_ByteString result;
\r
78 for (FX_INT32 i = 0; i < m_codewords->GetSize(); i++) {
\r
79 CBC_Codeword* codeword = (CBC_Codeword*)m_codewords->GetAt(i);
\r
80 if (codeword == NULL) {
\r
81 result += (FX_CHAR) row;
\r
85 result += (FX_CHAR) row;
\r
86 result += codeword->getRowNumber();
\r
87 result += codeword->getValue();
\r