~ubuntu-branches/ubuntu/saucy/digikam/saucy

« back to all changes in this revision

Viewing changes to libs/dimg/filters/lens/antivignettingfilter.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Alessandro Ghersi
  • Date: 2010-06-18 21:58:46 UTC
  • mfrom: (1.2.29 upstream) (3.2.13 sid)
  • Revision ID: james.westby@ubuntu.com-20100618215846-c95bk5aoysmu786d
Tags: 2:1.3.0-0ubuntu1
* Merge with Debian unstable, remaining changes:
  - Export .pot name and copy to plugins in debian/rules
  - Enable Nepomuk support in Digikam
    - Add shared-desktop-ontologies to build depends
* New upstream release:
  - Remove digikam-1.2.0-kde232628.patch fixed by upstream
  - Add mysql-server-5.1 to buil-depends

Show diffs side-by-side

added added

removed removed

Lines of Context:
74
74
    int Height = m_orgImage.height();
75
75
 
76
76
    // Determine the shift in pixels from the shift in percentage.
77
 
    m_settings.xshift   = m_settings.xshift*Height/200.0;
78
 
    m_settings.yshift   = m_settings.yshift*Width /200.0;
 
77
    m_settings.yshift   = m_settings.yshift*Height/200.0;
 
78
    m_settings.xshift   = m_settings.xshift*Width /200.0;
79
79
 
80
80
    // Determine the outer radius of the filter.  This is the half diagonal
81
81
    // measure of the image multiplied by the radius factor.
82
82
 
83
83
    xsize    = (Height + 1) / 2;
84
84
    ysize    = (Width  + 1) / 2;
85
 
    erad     = approx(hypothenuse(xsize,ysize) * m_settings.outerradius);
86
 
    irad     = approx(hypothenuse(xsize,ysize) * m_settings.outerradius * m_settings.innerradius);
87
 
 
88
 
    xsize    = ((Height + 1) / 2) + abs(m_settings.xshift);
89
 
    ysize    = ((Width  + 1) / 2) + abs(m_settings.yshift);
90
 
    diagonal = approx(hypothenuse(xsize,ysize)) +  1;
91
 
 
92
 
    xctr     = ((Height + 1) / 2) + m_settings.xshift;
93
 
    yctr     = ((Width  + 1) / 2) + m_settings.yshift;
94
 
 
95
 
    for (row = 0 ; !m_cancel && (row < Width) ; ++row)
 
85
    erad     = qRound(hypothenuse(xsize, ysize) * m_settings.outerradius);
 
86
    irad     = qRound(hypothenuse(xsize, ysize) * m_settings.outerradius * m_settings.innerradius);
 
87
 
 
88
    xsize    = qRound(Width  / 2.0 + fabs(m_settings.xshift));
 
89
    ysize    = qRound(Height / 2.0 + fabs(m_settings.yshift));
 
90
 
 
91
    diagonal = qRound(hypothenuse(xsize,ysize)) +  1;
 
92
 
 
93
    xctr     = qRound(Width  / 2.0 + m_settings.xshift);
 
94
    yctr     = qRound(Height / 2.0 + m_settings.yshift);
 
95
 
 
96
 
 
97
    for (row = 0 ; runningFlag() && (row < Width) ; ++row)
96
98
    {
97
 
        yd = abs(yctr - row);
 
99
        yd = abs(xctr - row);
98
100
 
99
 
        for (col = 0 ; !m_cancel && (col < Height) ; ++col)
 
101
        for (col = 0 ; runningFlag() && (col < Height) ; ++col)
100
102
        {
101
103
            p  = (col * Width + row)*4;
102
 
            xd = abs(xctr - col);
103
 
            td = (sqrt((xd * xd) + (yd * yd)) + 0.5);
 
104
            xd = abs(yctr - col);
 
105
            td = qRound(hypothenuse(xd,yd));
104
106
 
105
107
            if (!m_orgImage.sixteenBit())       // 8 bits image
106
108
            {
111
113
            }
112
114
            else                                // 16 bits image.
113
115
            {
114
 
                NewBits16[ p ] = clamp16bits(data16[ p ] * real_attenuation(erad/2,erad,td));
115
 
                NewBits16[p+1] = clamp16bits(data16[p+1] * real_attenuation(erad/2,erad,td));
116
 
                NewBits16[p+2] = clamp16bits(data16[p+2] * real_attenuation(erad/2,erad,td));
 
116
                NewBits16[ p ] = clamp16bits(data16[ p ] * real_attenuation(irad,erad,td));
 
117
                NewBits16[p+1] = clamp16bits(data16[p+1] * real_attenuation(irad,erad,td));
 
118
                NewBits16[p+2] = clamp16bits(data16[p+2] * real_attenuation(irad,erad,td));
117
119
                NewBits16[p+3] = data16[p+3];
118
120
            }
119
121
        }
125
127
    }
126
128
}
127
129
 
128
 
int AntiVignettingFilter::approx(double x)
129
 
{
130
 
    return ((int) x+0.5);
131
 
}
132
 
 
133
 
double AntiVignettingFilter::hypothenuse(double x, double y)
 
130
inline double AntiVignettingFilter::hypothenuse(double x, double y)
134
131
{
135
132
    return (sqrt (x*x + y*y));
136
133
}