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

« back to all changes in this revision

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

  • Committer: Bazaar Package Importer
  • Author(s): Scott Kitterman
  • Date: 2010-12-21 23:19:11 UTC
  • mfrom: (1.2.33 upstream) (3.1.7 experimental)
  • Revision ID: james.westby@ubuntu.com-20101221231911-z9jip7s5aht1jqn9
Tags: 2:1.7.0-1ubuntu1
* Merge from Debian Experimental. Remaining Ubuntu changes:
  - Export .pot name and copy to plugins in debian/rules
  - Version build-depends on kipi-plugins-dev to ensure build is against the
    same version on all archs
* Drop debian/patches/kubuntu_01_linker.diff, incoporated upstream
* Remove patches directory and unused patches

Show diffs side-by-side

added added

removed removed

Lines of Context:
58
58
 
59
59
PixelAccess::~PixelAccess()
60
60
{
61
 
    for( int i = 0 ; i < PixelAccessRegions ; ++i )
62
 
       delete m_buffer[i];
 
61
    for ( int i = 0 ; i < PixelAccessRegions ; ++i )
 
62
    {
 
63
        delete m_buffer[i];
 
64
    }
63
65
}
64
66
 
65
67
uchar* PixelAccess::pixelAccessAddress(int i, int j)
80
82
    c    = m_tileMinY[n];
81
83
    d    = m_tileMaxY[n];
82
84
 
83
 
    for( i = n ; i > 0 ; --i)
 
85
    for ( i = n ; i > 0 ; --i)
84
86
    {
85
87
        m_buffer[i]   = m_buffer[i-1];
86
88
        m_tileMinX[i] = m_tileMinX[i-1];
105
107
    uchar* line;
106
108
 
107
109
    lineStart = i;
108
 
    if (lineStart < 0) lineStart = 0;
 
110
 
 
111
    if (lineStart < 0)
 
112
    {
 
113
        lineStart = 0;
 
114
    }
 
115
 
109
116
    lineEnd = i + m_width;
110
 
    if (lineEnd > m_imageWidth) lineEnd = m_imageWidth;
 
117
 
 
118
    if (lineEnd > m_imageWidth)
 
119
    {
 
120
        lineEnd = m_imageWidth;
 
121
    }
 
122
 
111
123
    lineWidth = lineEnd - lineStart;
112
124
 
113
125
    if ( lineStart >= lineEnd )
114
 
       return;
 
126
    {
 
127
        return;
 
128
    }
115
129
 
116
130
    rowStart = j;
117
 
    if (rowStart < 0) rowStart = 0;
 
131
 
 
132
    if (rowStart < 0)
 
133
    {
 
134
        rowStart = 0;
 
135
    }
 
136
 
118
137
    rowEnd = j + m_height;
119
 
    if (rowEnd > m_imageHeight) rowEnd = m_imageHeight;
120
 
 
121
 
    for( int y = rowStart ; y < rowEnd ; ++y )
 
138
 
 
139
    if (rowEnd > m_imageHeight)
 
140
    {
 
141
        rowEnd = m_imageHeight;
 
142
    }
 
143
 
 
144
    for ( int y = rowStart ; y < rowEnd ; ++y )
122
145
    {
123
146
        line = pixelAccessAddress(lineStart, y);
124
147
        memcpy(line, m_image->scanLine(y) + lineStart * m_depth, lineWidth * m_depth);
138
161
 
139
162
 
140
163
    if ( (newStartX < 0) || ((newStartX + m_width) >= m_imageWidth) ||
141
 
          (newStartY < 0) || ((newStartY + m_height) >= m_imageHeight) )
 
164
         (newStartY < 0) || ((newStartY + m_height) >= m_imageHeight) )
142
165
    {
143
166
        // some data is off edge of image
144
167
 
149
172
        //m_buffer[0]->bitBltImage(m_image, newStartX, newStartY, m_width, m_height, 0, 0);
150
173
 
151
174
        if ( ((newStartX + m_width) < 0) || (newStartX >= m_imageWidth) ||
152
 
               ((newStartY + m_height) < 0) || (newStartY >= m_imageHeight) )
 
175
             ((newStartY + m_height) < 0) || (newStartY >= m_imageHeight) )
153
176
        {
154
 
          // totally outside, just leave it.
 
177
            // totally outside, just leave it.
155
178
        }
156
179
        else
157
180
        {
179
202
    // they're probably in the last place we looked...
180
203
 
181
204
    if ((xInt >= m_tileMinX[0]) && (xInt < m_tileMaxX[0]) &&
182
 
         (yInt >= m_tileMinY[0]) && (yInt < m_tileMaxY[0]) )
 
205
        (yInt >= m_tileMinY[0]) && (yInt < m_tileMaxY[0]) )
183
206
    {
184
207
        corner = pixelAccessAddress(xInt - 1, yInt - 1);
185
208
        cubicInterpolate(corner, m_depth * m_width, dst, m_sixteenBit, dx, dy, brighten);
191
214
    for ( int i = 1 ; i < PixelAccessRegions ; ++i)
192
215
    {
193
216
        if ((xInt >= m_tileMinX[i]) && (xInt < m_tileMaxX[i]) &&
194
 
             (yInt >= m_tileMinY[i]) && (yInt < m_tileMaxY[i]) )
 
217
            (yInt >= m_tileMinY[i]) && (yInt < m_tileMaxY[i]) )
195
218
        {
196
219
            // Check here first next time
197
220
 
244
267
 
245
268
    if (sixteenBit)
246
269
    {
247
 
        unsigned short *src16 = (unsigned short *)src;
248
 
        unsigned short *dst16 = (unsigned short *)dst;
 
270
        unsigned short* src16 = (unsigned short*)src;
 
271
        unsigned short* dst16 = (unsigned short*)dst;
249
272
 
250
273
        // for each component, read the values of 4 pixels into array
251
274