| 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 2007 ZXing authors | 8 * Copyright 2007 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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 CBC_QRDetectorResult* CBC_QRDetector::ProcessFinderPatternInfo( | 49 CBC_QRDetectorResult* CBC_QRDetector::ProcessFinderPatternInfo( |
| 50 CBC_QRFinderPatternInfo* info, | 50 CBC_QRFinderPatternInfo* info, |
| 51 int32_t& e) { | 51 int32_t& e) { |
| 52 std::unique_ptr<CBC_QRFinderPattern> topLeft(info->GetTopLeft()); | 52 std::unique_ptr<CBC_QRFinderPattern> topLeft(info->GetTopLeft()); |
| 53 std::unique_ptr<CBC_QRFinderPattern> topRight(info->GetTopRight()); | 53 std::unique_ptr<CBC_QRFinderPattern> topRight(info->GetTopRight()); |
| 54 std::unique_ptr<CBC_QRFinderPattern> bottomLeft(info->GetBottomLeft()); | 54 std::unique_ptr<CBC_QRFinderPattern> bottomLeft(info->GetBottomLeft()); |
| 55 FX_FLOAT moduleSize = | 55 FX_FLOAT moduleSize = |
| 56 CalculateModuleSize(topLeft.get(), topRight.get(), bottomLeft.get()); | 56 CalculateModuleSize(topLeft.get(), topRight.get(), bottomLeft.get()); |
| 57 if (moduleSize < 1.0f) { | 57 if (moduleSize < 1.0f) { |
| 58 e = BCExceptionRead; | 58 e = BCExceptionRead; |
| 59 BC_EXCEPTION_CHECK_ReturnValue(e, NULL); | 59 return nullptr; |
| 60 } | 60 } |
| 61 int32_t dimension = ComputeDimension(topLeft.get(), topRight.get(), | 61 int32_t dimension = ComputeDimension(topLeft.get(), topRight.get(), |
| 62 bottomLeft.get(), moduleSize, e); | 62 bottomLeft.get(), moduleSize, e); |
| 63 BC_EXCEPTION_CHECK_ReturnValue(e, NULL); | 63 BC_EXCEPTION_CHECK_ReturnValue(e, nullptr); |
| 64 CBC_QRCoderVersion* provisionalVersion = | 64 CBC_QRCoderVersion* provisionalVersion = |
| 65 CBC_QRCoderVersion::GetProvisionalVersionForDimension(dimension, e); | 65 CBC_QRCoderVersion::GetProvisionalVersionForDimension(dimension, e); |
| 66 BC_EXCEPTION_CHECK_ReturnValue(e, NULL); | 66 BC_EXCEPTION_CHECK_ReturnValue(e, nullptr); |
| 67 int32_t modulesBetweenFPCenters = | 67 int32_t modulesBetweenFPCenters = |
| 68 provisionalVersion->GetDimensionForVersion() - 7; | 68 provisionalVersion->GetDimensionForVersion() - 7; |
| 69 CBC_QRAlignmentPattern* alignmentPattern = NULL; | 69 CBC_QRAlignmentPattern* alignmentPattern = nullptr; |
| 70 if (provisionalVersion->GetAlignmentPatternCenters()->GetSize() > 0) { | 70 if (provisionalVersion->GetAlignmentPatternCenters()->GetSize() > 0) { |
| 71 FX_FLOAT bottomRightX = | 71 FX_FLOAT bottomRightX = |
| 72 topRight->GetX() - topLeft->GetX() + bottomLeft->GetX(); | 72 topRight->GetX() - topLeft->GetX() + bottomLeft->GetX(); |
| 73 FX_FLOAT bottomRightY = | 73 FX_FLOAT bottomRightY = |
| 74 topRight->GetY() - topLeft->GetY() + bottomLeft->GetY(); | 74 topRight->GetY() - topLeft->GetY() + bottomLeft->GetY(); |
| 75 FX_FLOAT correctionToTopLeft = | 75 FX_FLOAT correctionToTopLeft = |
| 76 1.0f - 3.0f / (FX_FLOAT)modulesBetweenFPCenters; | 76 1.0f - 3.0f / (FX_FLOAT)modulesBetweenFPCenters; |
| 77 FX_FLOAT xtemp = (topLeft->GetX() + | 77 FX_FLOAT xtemp = (topLeft->GetX() + |
| 78 correctionToTopLeft * (bottomRightX - topLeft->GetX())); | 78 correctionToTopLeft * (bottomRightX - topLeft->GetX())); |
| 79 int32_t estAlignmentX = (int32_t)xtemp; | 79 int32_t estAlignmentX = (int32_t)xtemp; |
| 80 FX_FLOAT ytemp = (topLeft->GetY() + | 80 FX_FLOAT ytemp = (topLeft->GetY() + |
| 81 correctionToTopLeft * (bottomRightY - topLeft->GetY())); | 81 correctionToTopLeft * (bottomRightY - topLeft->GetY())); |
| 82 int32_t estAlignmentY = (int32_t)ytemp; | 82 int32_t estAlignmentY = (int32_t)ytemp; |
| 83 for (int32_t i = 4; i <= 16; i <<= 1) { | 83 for (int32_t i = 4; i <= 16; i <<= 1) { |
| 84 CBC_QRAlignmentPattern* temp = FindAlignmentInRegion( | 84 CBC_QRAlignmentPattern* temp = FindAlignmentInRegion( |
| 85 moduleSize, estAlignmentX, estAlignmentY, (FX_FLOAT)i, e); | 85 moduleSize, estAlignmentX, estAlignmentY, (FX_FLOAT)i, e); |
| 86 alignmentPattern = temp; | 86 if (temp) { |
| 87 break; | 87 alignmentPattern = temp; |
| 88 break; |
| 89 } |
| 88 } | 90 } |
| 89 } | 91 } |
| 90 CBC_CommonBitMatrix* bits = | 92 CBC_CommonBitMatrix* bits = |
| 91 SampleGrid(m_image, topLeft.get(), topRight.get(), bottomLeft.get(), | 93 SampleGrid(m_image, topLeft.get(), topRight.get(), bottomLeft.get(), |
| 92 (CBC_ResultPoint*)(alignmentPattern), dimension, e); | 94 (CBC_ResultPoint*)(alignmentPattern), dimension, e); |
| 93 BC_EXCEPTION_CHECK_ReturnValue(e, NULL); | 95 BC_EXCEPTION_CHECK_ReturnValue(e, NULL); |
| 94 | 96 |
| 95 CFX_ArrayTemplate<CBC_ResultPoint*>* points = | 97 CFX_ArrayTemplate<CBC_ResultPoint*>* points = |
| 96 new CFX_ArrayTemplate<CBC_ResultPoint*>(); | 98 new CFX_ArrayTemplate<CBC_ResultPoint*>(); |
| 97 points->Add(bottomLeft.release()); | 99 points->Add(bottomLeft.release()); |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 267 int32_t alignmentAreaBottomY = | 269 int32_t alignmentAreaBottomY = |
| 268 std::min(m_image->GetHeight() - 1, estAlignmentY + allowance); | 270 std::min(m_image->GetHeight() - 1, estAlignmentY + allowance); |
| 269 CBC_QRAlignmentPatternFinder alignmentFinder( | 271 CBC_QRAlignmentPatternFinder alignmentFinder( |
| 270 m_image, alignmentAreaLeftX, alignmentAreaTopY, | 272 m_image, alignmentAreaLeftX, alignmentAreaTopY, |
| 271 alignmentAreaRightX - alignmentAreaLeftX, | 273 alignmentAreaRightX - alignmentAreaLeftX, |
| 272 alignmentAreaBottomY - alignmentAreaTopY, overallEstModuleSize); | 274 alignmentAreaBottomY - alignmentAreaTopY, overallEstModuleSize); |
| 273 CBC_QRAlignmentPattern* qap = alignmentFinder.Find(e); | 275 CBC_QRAlignmentPattern* qap = alignmentFinder.Find(e); |
| 274 BC_EXCEPTION_CHECK_ReturnValue(e, NULL); | 276 BC_EXCEPTION_CHECK_ReturnValue(e, NULL); |
| 275 return qap; | 277 return qap; |
| 276 } | 278 } |
| OLD | NEW |