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"); |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
134 for (int32_t i = rowOffset; i < width; i++) { | 134 for (int32_t i = rowOffset; i < width; i++) { |
135 FX_BOOL pixel = row->Get(i); | 135 FX_BOOL pixel = row->Get(i); |
136 if (pixel ^ isWhite) { | 136 if (pixel ^ isWhite) { |
137 counters[counterPosition]++; | 137 counters[counterPosition]++; |
138 } else { | 138 } else { |
139 if (counterPosition == patternLength - 1) { | 139 if (counterPosition == patternLength - 1) { |
140 if (ToNarrowWidePattern(&counters) == ASTERISK_ENCODING) { | 140 if (ToNarrowWidePattern(&counters) == ASTERISK_ENCODING) { |
141 FX_BOOL bT1 = | 141 FX_BOOL bT1 = |
142 row->IsRange(std::max(0, patternStart - (i - patternStart) / 2), | 142 row->IsRange(std::max(0, patternStart - (i - patternStart) / 2), |
143 patternStart, FALSE, e); | 143 patternStart, FALSE, e); |
144 BC_EXCEPTION_CHECK_ReturnValue(e, NULL); | 144 BC_EXCEPTION_CHECK_ReturnValue(e, nullptr); |
145 if (bT1) { | 145 if (bT1) { |
146 CFX_Int32Array* result = new CFX_Int32Array; | 146 CFX_Int32Array* result = new CFX_Int32Array; |
147 result->SetSize(2); | 147 result->SetSize(2); |
148 (*result)[0] = patternStart; | 148 (*result)[0] = patternStart; |
149 (*result)[1] = i; | 149 (*result)[1] = i; |
150 return result; | 150 return result; |
151 } | 151 } |
152 } | 152 } |
153 patternStart += counters[0] + counters[1]; | 153 patternStart += counters[0] + counters[1]; |
154 for (int32_t y = 2; y < patternLength; y++) { | 154 for (int32_t y = 2; y < patternLength; y++) { |
155 counters[y - 2] = counters[y]; | 155 counters[y - 2] = counters[y]; |
156 } | 156 } |
157 counters[patternLength - 2] = 0; | 157 counters[patternLength - 2] = 0; |
158 counters[patternLength - 1] = 0; | 158 counters[patternLength - 1] = 0; |
159 counterPosition--; | 159 counterPosition--; |
160 } else { | 160 } else { |
161 counterPosition++; | 161 counterPosition++; |
162 } | 162 } |
163 counters[counterPosition] = 1; | 163 counters[counterPosition] = 1; |
164 isWhite = !isWhite; | 164 isWhite = !isWhite; |
165 } | 165 } |
166 } | 166 } |
167 e = BCExceptionNotFound; | 167 e = BCExceptionNotFound; |
168 return NULL; | 168 return nullptr; |
169 } | 169 } |
170 int32_t CBC_OnedCode39Reader::ToNarrowWidePattern(CFX_Int32Array* counters) { | 170 int32_t CBC_OnedCode39Reader::ToNarrowWidePattern(CFX_Int32Array* counters) { |
171 int32_t numCounters = counters->GetSize(); | 171 int32_t numCounters = counters->GetSize(); |
172 int32_t maxNarrowCounter = 0; | 172 int32_t maxNarrowCounter = 0; |
173 int32_t wideCounters; | 173 int32_t wideCounters; |
174 do { | 174 do { |
175 #undef max | 175 #undef max |
176 int32_t minCounter = FXSYS_IntMax; | 176 int32_t minCounter = FXSYS_IntMax; |
177 for (int32_t i = 0; i < numCounters; i++) { | 177 for (int32_t i = 0; i < numCounters; i++) { |
178 int32_t counter = (*counters)[i]; | 178 int32_t counter = (*counters)[i]; |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
277 break; | 277 break; |
278 } | 278 } |
279 decoded += decodedChar; | 279 decoded += decodedChar; |
280 i++; | 280 i++; |
281 } else { | 281 } else { |
282 decoded += c; | 282 decoded += c; |
283 } | 283 } |
284 } | 284 } |
285 return decoded; | 285 return decoded; |
286 } | 286 } |
OLD | NEW |