| 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_ResultPoint.h" | 26 #include "xfa/src/fxbarcode/BC_ResultPoint.h" |
| 25 #include "xfa/src/fxbarcode/common/BC_WhiteRectangleDetector.h" | 27 #include "xfa/src/fxbarcode/common/BC_WhiteRectangleDetector.h" |
| 26 #include "xfa/src/fxbarcode/common/BC_CommonBitMatrix.h" | 28 #include "xfa/src/fxbarcode/common/BC_CommonBitMatrix.h" |
| 27 #include "xfa/src/fxbarcode/qrcode/BC_QRFinderPatternFinder.h" | 29 #include "xfa/src/fxbarcode/qrcode/BC_QRFinderPatternFinder.h" |
| 28 #include "xfa/src/fxbarcode/qrcode/BC_QRDetectorResult.h" | 30 #include "xfa/src/fxbarcode/qrcode/BC_QRDetectorResult.h" |
| 29 #include "xfa/src/fxbarcode/qrcode/BC_QRGridSampler.h" | 31 #include "xfa/src/fxbarcode/qrcode/BC_QRGridSampler.h" |
| 30 #include "BC_DataMatrixDetector.h" | 32 #include "BC_DataMatrixDetector.h" |
| 31 const int32_t CBC_DataMatrixDetector::INTEGERS[5] = {0, 1, 2, 3, 4}; | 33 const int32_t CBC_DataMatrixDetector::INTEGERS[5] = {0, 1, 2, 3, 4}; |
| 32 CBC_DataMatrixDetector::CBC_DataMatrixDetector(CBC_CommonBitMatrix* image) | 34 CBC_DataMatrixDetector::CBC_DataMatrixDetector(CBC_CommonBitMatrix* image) |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 159 dimensionTop++; | 161 dimensionTop++; |
| 160 } | 162 } |
| 161 if ((dimensionRight & 0x01) == 1) { | 163 if ((dimensionRight & 0x01) == 1) { |
| 162 dimensionRight++; | 164 dimensionRight++; |
| 163 } | 165 } |
| 164 bits = CBC_AutoPtr<CBC_CommonBitMatrix>( | 166 bits = CBC_AutoPtr<CBC_CommonBitMatrix>( |
| 165 SampleGrid(m_image, topLeft, bottomLeft, bottomRight, | 167 SampleGrid(m_image, topLeft, bottomLeft, bottomRight, |
| 166 correctedTopRight.get(), dimensionTop, dimensionRight, e)); | 168 correctedTopRight.get(), dimensionTop, dimensionRight, e)); |
| 167 BC_EXCEPTION_CHECK_ReturnValue(e, NULL); | 169 BC_EXCEPTION_CHECK_ReturnValue(e, NULL); |
| 168 } else { | 170 } else { |
| 169 int32_t dimension = FX_MIN(dimensionRight, dimensionTop); | 171 int32_t dimension = std::min(dimensionRight, dimensionTop); |
| 170 correctedTopRight = CBC_AutoPtr<CBC_ResultPoint>( | 172 correctedTopRight = CBC_AutoPtr<CBC_ResultPoint>( |
| 171 CorrectTopRight(bottomLeft, bottomRight, topLeft, topRight, dimension)); | 173 CorrectTopRight(bottomLeft, bottomRight, topLeft, topRight, dimension)); |
| 172 if (correctedTopRight.get() == NULL) { | 174 if (correctedTopRight.get() == NULL) { |
| 173 correctedTopRight = CBC_AutoPtr<CBC_ResultPoint>(topRight); | 175 correctedTopRight = CBC_AutoPtr<CBC_ResultPoint>(topRight); |
| 174 } else { | 176 } else { |
| 175 delete topRight; | 177 delete topRight; |
| 176 topRight = NULL; | 178 topRight = NULL; |
| 177 } | 179 } |
| 178 int32_t dimensionCorrected = | 180 int32_t dimensionCorrected = |
| 179 FX_MAX(CBC_AutoPtr<CBC_ResultPointsAndTransitions>( | 181 std::max(CBC_AutoPtr<CBC_ResultPointsAndTransitions>( |
| 180 TransitionsBetween(topLeft, correctedTopRight.get())) | 182 TransitionsBetween(topLeft, correctedTopRight.get())) |
| 181 ->GetTransitions(), | 183 ->GetTransitions(), |
| 182 CBC_AutoPtr<CBC_ResultPointsAndTransitions>( | 184 CBC_AutoPtr<CBC_ResultPointsAndTransitions>( |
| 183 TransitionsBetween(bottomRight, correctedTopRight.get())) | 185 TransitionsBetween(bottomRight, correctedTopRight.get())) |
| 184 ->GetTransitions()); | 186 ->GetTransitions()); |
| 185 dimensionCorrected++; | 187 dimensionCorrected++; |
| 186 if ((dimensionCorrected & 0x01) == 1) { | 188 if ((dimensionCorrected & 0x01) == 1) { |
| 187 dimensionCorrected++; | 189 dimensionCorrected++; |
| 188 } | 190 } |
| 189 bits = CBC_AutoPtr<CBC_CommonBitMatrix>(SampleGrid( | 191 bits = CBC_AutoPtr<CBC_CommonBitMatrix>(SampleGrid( |
| 190 m_image, topLeft, bottomLeft, bottomRight, correctedTopRight.get(), | 192 m_image, topLeft, bottomLeft, bottomRight, correctedTopRight.get(), |
| 191 dimensionCorrected, dimensionCorrected, e)); | 193 dimensionCorrected, dimensionCorrected, e)); |
| 192 BC_EXCEPTION_CHECK_ReturnValue(e, NULL); | 194 BC_EXCEPTION_CHECK_ReturnValue(e, NULL); |
| 193 } | 195 } |
| 194 CFX_PtrArray* result = new CFX_PtrArray; | 196 CFX_PtrArray* result = new CFX_PtrArray; |
| (...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 395 (bottomLeft->GetX() - topLeft->GetX()) * | 397 (bottomLeft->GetX() - topLeft->GetX()) * |
| 396 (topRight->GetY() - topLeft->GetY())) { | 398 (topRight->GetY() - topLeft->GetY())) { |
| 397 CBC_ResultPoint* temp = topRight; | 399 CBC_ResultPoint* temp = topRight; |
| 398 topRight = bottomLeft; | 400 topRight = bottomLeft; |
| 399 bottomLeft = temp; | 401 bottomLeft = temp; |
| 400 } | 402 } |
| 401 (*patterns)[0] = bottomLeft; | 403 (*patterns)[0] = bottomLeft; |
| 402 (*patterns)[1] = topLeft; | 404 (*patterns)[1] = topLeft; |
| 403 (*patterns)[2] = topRight; | 405 (*patterns)[2] = topRight; |
| 404 } | 406 } |
| OLD | NEW |