OLD | NEW |
1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 PDFium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
6 // Original code is licensed as follows: | 6 // Original code is licensed as follows: |
7 /* | 7 /* |
8 * Copyright 2008 ZXing authors | 8 * Copyright 2008 ZXing authors |
9 * | 9 * |
10 * Licensed under the Apache License, Version 2.0 (the "License"); | 10 * Licensed under the Apache License, Version 2.0 (the "License"); |
11 * you may not use this file except in compliance with 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 | 12 * You may obtain a copy of the License at |
13 * | 13 * |
14 * http://www.apache.org/licenses/LICENSE-2.0 | 14 * http://www.apache.org/licenses/LICENSE-2.0 |
15 * | 15 * |
16 * Unless required by applicable law or agreed to in writing, software | 16 * Unless required by applicable law or agreed to in writing, software |
17 * distributed under the License is distributed on an "AS IS" BASIS, | 17 * distributed under the License is distributed on an "AS IS" BASIS, |
18 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | 18 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
19 * See the License for the specific language governing permissions and | 19 * See the License for the specific language governing permissions and |
20 * limitations under the License. | 20 * limitations under the License. |
21 */ | 21 */ |
22 | 22 |
| 23 #include <algorithm> |
| 24 |
23 #include "xfa/src/fxbarcode/barcode.h" | 25 #include "xfa/src/fxbarcode/barcode.h" |
24 #include "xfa/src/fxbarcode/BC_Reader.h" | 26 #include "xfa/src/fxbarcode/BC_Reader.h" |
25 #include "xfa/src/fxbarcode/common/BC_CommonBitArray.h" | 27 #include "xfa/src/fxbarcode/common/BC_CommonBitArray.h" |
26 #include "BC_OneDReader.h" | 28 #include "BC_OneDReader.h" |
27 #include "BC_OnedCode39Reader.h" | 29 #include "BC_OnedCode39Reader.h" |
28 const FX_CHAR* CBC_OnedCode39Reader::ALPHABET_STRING = | 30 const FX_CHAR* CBC_OnedCode39Reader::ALPHABET_STRING = |
29 "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ-. *$/+%"; | 31 "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ-. *$/+%"; |
30 const FX_CHAR* CBC_OnedCode39Reader::CHECKSUM_STRING = | 32 const FX_CHAR* CBC_OnedCode39Reader::CHECKSUM_STRING = |
31 "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ-. $/+%"; | 33 "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ-. $/+%"; |
32 const int32_t CBC_OnedCode39Reader::CHARACTER_ENCODINGS[44] = { | 34 const int32_t CBC_OnedCode39Reader::CHARACTER_ENCODINGS[44] = { |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
137 FX_BOOL isWhite = FALSE; | 139 FX_BOOL isWhite = FALSE; |
138 int32_t patternLength = counters.GetSize(); | 140 int32_t patternLength = counters.GetSize(); |
139 for (int32_t i = rowOffset; i < width; i++) { | 141 for (int32_t i = rowOffset; i < width; i++) { |
140 FX_BOOL pixel = row->Get(i); | 142 FX_BOOL pixel = row->Get(i); |
141 if (pixel ^ isWhite) { | 143 if (pixel ^ isWhite) { |
142 counters[counterPosition]++; | 144 counters[counterPosition]++; |
143 } else { | 145 } else { |
144 if (counterPosition == patternLength - 1) { | 146 if (counterPosition == patternLength - 1) { |
145 if (ToNarrowWidePattern(&counters) == ASTERISK_ENCODING) { | 147 if (ToNarrowWidePattern(&counters) == ASTERISK_ENCODING) { |
146 FX_BOOL bT1 = | 148 FX_BOOL bT1 = |
147 row->IsRange(FX_MAX(0, patternStart - (i - patternStart) / 2), | 149 row->IsRange(std::max(0, patternStart - (i - patternStart) / 2), |
148 patternStart, FALSE, e); | 150 patternStart, FALSE, e); |
149 BC_EXCEPTION_CHECK_ReturnValue(e, NULL); | 151 BC_EXCEPTION_CHECK_ReturnValue(e, NULL); |
150 if (bT1) { | 152 if (bT1) { |
151 CFX_Int32Array* result = new CFX_Int32Array; | 153 CFX_Int32Array* result = new CFX_Int32Array; |
152 result->SetSize(2); | 154 result->SetSize(2); |
153 (*result)[0] = patternStart; | 155 (*result)[0] = patternStart; |
154 (*result)[1] = i; | 156 (*result)[1] = i; |
155 return result; | 157 return result; |
156 } | 158 } |
157 } | 159 } |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
282 break; | 284 break; |
283 } | 285 } |
284 decoded += decodedChar; | 286 decoded += decodedChar; |
285 i++; | 287 i++; |
286 } else { | 288 } else { |
287 decoded += c; | 289 decoded += c; |
288 } | 290 } |
289 } | 291 } |
290 return decoded; | 292 return decoded; |
291 } | 293 } |
OLD | NEW |