summaryrefslogtreecommitdiff
path: root/xfa/src/fxbarcode/src/BC_QRFinderPattern.cpp
blob: 90222d301a64ca237657e80a55c751a1902f776c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
// Copyright 2014 PDFium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com

#include "barcode.h"
#include "include/BC_ResultPoint.h"
#include "include/BC_QRFinderPattern.h"
CBC_QRFinderPattern::CBC_QRFinderPattern(FX_FLOAT x, FX_FLOAT posY, FX_FLOAT estimatedModuleSize):
    CBC_ResultPoint(x, posY),
    m_estimatedModuleSize(estimatedModuleSize), m_count(1)
{
}
CBC_QRFinderPattern::~CBC_QRFinderPattern()
{
    m_count = 0;
    m_x = 0.0f;
    m_y = 0.0f;
    m_estimatedModuleSize = 0.0f;
}
CBC_QRFinderPattern *CBC_QRFinderPattern::Clone()
{
    CBC_QRFinderPattern *temp = FX_NEW CBC_QRFinderPattern(m_x, m_y, m_estimatedModuleSize);
    temp->m_count = m_count;
    return temp;
}
FX_FLOAT CBC_QRFinderPattern::GetEstimatedModuleSize()
{
    return m_estimatedModuleSize;
}
FX_INT32 CBC_QRFinderPattern::GetCount()
{
    return m_count;
}
void CBC_QRFinderPattern::IncrementCount()
{
    m_count++;
}
FX_BOOL CBC_QRFinderPattern::AboutEquals(FX_FLOAT moduleSize, FX_FLOAT i, FX_FLOAT j)
{
    if((fabs(i - GetY()) <= moduleSize) && (fabs(j - GetX()) <= moduleSize)) {
        FX_FLOAT moduleSizeDiff = fabs(moduleSize - m_estimatedModuleSize);
        return (moduleSizeDiff <= 1.0f) || (moduleSizeDiff / m_estimatedModuleSize <= 1.0f);
    }
    return false;
}
FX_FLOAT CBC_QRFinderPattern::GetX()
{
    return m_x;
}
FX_FLOAT CBC_QRFinderPattern::GetY()
{
    return m_y;
}