| 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 2009 ZXing authors | 8 * Copyright 2009 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 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 CFX_PtrArray* CBC_Detector::detect(FX_BOOL multiple, | 107 CFX_PtrArray* CBC_Detector::detect(FX_BOOL multiple, |
| 108 CBC_CommonBitMatrix* bitMatrix) { | 108 CBC_CommonBitMatrix* bitMatrix) { |
| 109 CFX_PtrArray* barcodeCoordinates = new CFX_PtrArray; | 109 CFX_PtrArray* barcodeCoordinates = new CFX_PtrArray; |
| 110 int32_t row = 0; | 110 int32_t row = 0; |
| 111 int32_t column = 0; | 111 int32_t column = 0; |
| 112 FX_BOOL foundBarcodeInRow = FALSE; | 112 FX_BOOL foundBarcodeInRow = FALSE; |
| 113 while (row < bitMatrix->GetHeight()) { | 113 while (row < bitMatrix->GetHeight()) { |
| 114 CFX_PtrArray* vertices = findVertices(bitMatrix, row, column); | 114 CFX_PtrArray* vertices = findVertices(bitMatrix, row, column); |
| 115 if (vertices->GetAt(0) == NULL && vertices->GetAt(3) == NULL) { | 115 if (vertices->GetAt(0) == NULL && vertices->GetAt(3) == NULL) { |
| 116 if (!foundBarcodeInRow) { | 116 if (!foundBarcodeInRow) { |
| 117 if (vertices) { | 117 delete vertices; |
| 118 delete (vertices); | |
| 119 } | |
| 120 break; | 118 break; |
| 121 } | 119 } |
| 122 foundBarcodeInRow = FALSE; | 120 foundBarcodeInRow = FALSE; |
| 123 column = 0; | 121 column = 0; |
| 124 for (int32_t i = 0; i < barcodeCoordinates->GetSize(); i++) { | 122 for (int32_t i = 0; i < barcodeCoordinates->GetSize(); i++) { |
| 125 CFX_PtrArray* barcodeCoordinate = | 123 CFX_PtrArray* barcodeCoordinate = |
| 126 (CFX_PtrArray*)barcodeCoordinates->GetAt(i); | 124 (CFX_PtrArray*)barcodeCoordinates->GetAt(i); |
| 127 if (barcodeCoordinate->GetAt(1)) { | 125 if (barcodeCoordinate->GetAt(1)) { |
| 128 row = row > ((CBC_ResultPoint*)barcodeCoordinate->GetAt(1))->GetY(); | 126 row = row > ((CBC_ResultPoint*)barcodeCoordinate->GetAt(1))->GetY(); |
| 129 } | 127 } |
| 130 if (barcodeCoordinate->GetAt(3)) { | 128 if (barcodeCoordinate->GetAt(3)) { |
| 131 row = row > ((CBC_ResultPoint*)barcodeCoordinate->GetAt(3))->GetY(); | 129 row = row > ((CBC_ResultPoint*)barcodeCoordinate->GetAt(3))->GetY(); |
| 132 } | 130 } |
| 133 } | 131 } |
| 134 row += ROW_STEP; | 132 row += ROW_STEP; |
| 135 if (vertices) { | 133 delete vertices; |
| 136 delete (vertices); | |
| 137 } | |
| 138 continue; | 134 continue; |
| 139 } | 135 } |
| 140 foundBarcodeInRow = TRUE; | 136 foundBarcodeInRow = TRUE; |
| 141 barcodeCoordinates->Add(vertices); | 137 barcodeCoordinates->Add(vertices); |
| 142 if (!multiple) { | 138 if (!multiple) { |
| 143 break; | 139 break; |
| 144 } | 140 } |
| 145 if (vertices->GetAt(2)) { | 141 if (vertices->GetAt(2)) { |
| 146 column = (int32_t)((CBC_ResultPoint*)vertices->GetAt(2))->GetX(); | 142 column = (int32_t)((CBC_ResultPoint*)vertices->GetAt(2))->GetX(); |
| 147 row = (int32_t)((CBC_ResultPoint*)vertices->GetAt(2))->GetY(); | 143 row = (int32_t)((CBC_ResultPoint*)vertices->GetAt(2))->GetY(); |
| (...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 343 int32_t scaledPattern = pattern[x] * unitBarWidth; | 339 int32_t scaledPattern = pattern[x] * unitBarWidth; |
| 344 int32_t variance = counter > scaledPattern ? counter - scaledPattern | 340 int32_t variance = counter > scaledPattern ? counter - scaledPattern |
| 345 : scaledPattern - counter; | 341 : scaledPattern - counter; |
| 346 if (variance > maxIndividualVariance) { | 342 if (variance > maxIndividualVariance) { |
| 347 return INTEGER_MAX; | 343 return INTEGER_MAX; |
| 348 } | 344 } |
| 349 totalVariance += variance; | 345 totalVariance += variance; |
| 350 } | 346 } |
| 351 return totalVariance / total; | 347 return totalVariance / total; |
| 352 } | 348 } |
| OLD | NEW |