| OLD | NEW |
| (Empty) |
| 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 2008 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 "xfa/src/fxbarcode/BC_Reader.h" | |
| 24 #include "xfa/src/fxbarcode/common/BC_CommonBitArray.h" | |
| 25 #include "xfa/src/fxbarcode/oned/BC_OneDReader.h" | |
| 26 #include "xfa/src/fxbarcode/oned/BC_OneDimReader.h" | |
| 27 #include "xfa/src/fxbarcode/oned/BC_OnedEAN8Reader.h" | |
| 28 #include "xfa/src/fxbarcode/utils.h" | |
| 29 | |
| 30 CBC_OnedEAN8Reader::CBC_OnedEAN8Reader() {} | |
| 31 CBC_OnedEAN8Reader::~CBC_OnedEAN8Reader() {} | |
| 32 int32_t CBC_OnedEAN8Reader::DecodeMiddle(CBC_CommonBitArray* row, | |
| 33 CFX_Int32Array* startRange, | |
| 34 CFX_ByteString& resultResult, | |
| 35 int32_t& e) { | |
| 36 CFX_Int32Array counters; | |
| 37 counters.Add(0); | |
| 38 counters.Add(0); | |
| 39 counters.Add(0); | |
| 40 counters.Add(0); | |
| 41 int32_t end = row->GetSize(); | |
| 42 int32_t rowOffset = (*startRange)[1]; | |
| 43 int32_t rowOffsetLeft = rowOffset; | |
| 44 for (int32_t x = 0; x < 4 && rowOffset < end; x++) { | |
| 45 int32_t bestMatch = | |
| 46 DecodeDigit(row, &counters, rowOffset, | |
| 47 &(CBC_OneDimReader::L_PATTERNS[0][0]), 10, e); | |
| 48 BC_EXCEPTION_CHECK_ReturnValue(e, 0); | |
| 49 resultResult += (FX_CHAR)('0' + bestMatch); | |
| 50 for (int32_t i = 0; i < counters.GetSize(); i++) { | |
| 51 rowOffset += counters[i]; | |
| 52 } | |
| 53 } | |
| 54 int32_t RowOffsetLen = (rowOffset - rowOffsetLeft) / 4; | |
| 55 CFX_Int32Array result; | |
| 56 result.Add(CBC_OneDimReader::MIDDLE_PATTERN[0]); | |
| 57 result.Add(CBC_OneDimReader::MIDDLE_PATTERN[1]); | |
| 58 result.Add(CBC_OneDimReader::MIDDLE_PATTERN[2]); | |
| 59 result.Add(CBC_OneDimReader::MIDDLE_PATTERN[3]); | |
| 60 result.Add(CBC_OneDimReader::MIDDLE_PATTERN[4]); | |
| 61 CFX_Int32Array* middleRange = | |
| 62 FindGuardPattern(row, rowOffset, TRUE, &result, e); | |
| 63 BC_EXCEPTION_CHECK_ReturnValue(e, 0); | |
| 64 int32_t rowOffsetMid = rowOffset; | |
| 65 rowOffset = (*middleRange)[1]; | |
| 66 if ((rowOffset - rowOffsetMid) > RowOffsetLen) { | |
| 67 e = BCExceptionNotFound; | |
| 68 BC_EXCEPTION_CHECK_ReturnValue(e, 0); | |
| 69 } | |
| 70 delete middleRange; | |
| 71 for (int32_t y = 0; y < 4 && rowOffset < end; y++) { | |
| 72 int32_t bestMatch = | |
| 73 DecodeDigit(row, &counters, rowOffset, | |
| 74 &(CBC_OneDimReader::L_PATTERNS[0][0]), 10, e); | |
| 75 BC_EXCEPTION_CHECK_ReturnValue(e, 0); | |
| 76 resultResult += (FX_CHAR)('0' + bestMatch); | |
| 77 for (int32_t i = 0; i < counters.GetSize(); i++) { | |
| 78 rowOffset += counters[i]; | |
| 79 } | |
| 80 } | |
| 81 return rowOffset; | |
| 82 } | |
| OLD | NEW |