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

« back to all changes in this revision

Viewing changes to libs/dimg/filters/auto/normalizefilter.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:
40
40
{
41
41
 
42
42
NormalizeFilter::NormalizeFilter(DImg* orgImage, const DImg* refImage, QObject* parent)
43
 
               : DImgThreadedFilter(orgImage, parent, "NormalizeFilter"),
44
 
                 m_refImage(*refImage)
 
43
    : DImgThreadedFilter(orgImage, parent, "NormalizeFilter"),
 
44
      m_refImage(*refImage)
45
45
{
46
46
    initFilter();
47
47
}
72
72
 
73
73
    if (m_orgImage.sixteenBit() != m_refImage.sixteenBit())
74
74
    {
75
 
        kDebug() << "Ref. image and Org. has different bits depth"; 
 
75
        kDebug() << "Ref. image and Org. has different bits depth";
76
76
        return;
77
77
    }
78
78
 
100
100
            green = ptr[1];
101
101
            red   = ptr[2];
102
102
 
103
 
            if (red < param.min) param.min = red;
104
 
            if (red > param.max) param.max = red;
105
 
 
106
 
            if (green < param.min) param.min = green;
107
 
            if (green > param.max) param.max = green;
108
 
 
109
 
            if (blue < param.min) param.min = blue;
110
 
            if (blue > param.max) param.max = blue;
 
103
            if (red < param.min)
 
104
            {
 
105
                param.min = red;
 
106
            }
 
107
 
 
108
            if (red > param.max)
 
109
            {
 
110
                param.max = red;
 
111
            }
 
112
 
 
113
            if (green < param.min)
 
114
            {
 
115
                param.min = green;
 
116
            }
 
117
 
 
118
            if (green > param.max)
 
119
            {
 
120
                param.max = green;
 
121
            }
 
122
 
 
123
            if (blue < param.min)
 
124
            {
 
125
                param.min = blue;
 
126
            }
 
127
 
 
128
            if (blue > param.max)
 
129
            {
 
130
                param.max = blue;
 
131
            }
111
132
 
112
133
            ptr += 4;
113
134
        }
123
144
            green = ptr[1];
124
145
            red   = ptr[2];
125
146
 
126
 
            if (red < param.min) param.min = red;
127
 
            if (red > param.max) param.max = red;
128
 
 
129
 
            if (green < param.min) param.min = green;
130
 
            if (green > param.max) param.max = green;
131
 
 
132
 
            if (blue < param.min) param.min = blue;
133
 
            if (blue > param.max) param.max = blue;
 
147
            if (red < param.min)
 
148
            {
 
149
                param.min = red;
 
150
            }
 
151
 
 
152
            if (red > param.max)
 
153
            {
 
154
                param.max = red;
 
155
            }
 
156
 
 
157
            if (green < param.min)
 
158
            {
 
159
                param.min = green;
 
160
            }
 
161
 
 
162
            if (green > param.max)
 
163
            {
 
164
                param.max = green;
 
165
            }
 
166
 
 
167
            if (blue < param.min)
 
168
            {
 
169
                param.min = blue;
 
170
            }
 
171
 
 
172
            if (blue > param.max)
 
173
            {
 
174
                param.max = blue;
 
175
            }
134
176
 
135
177
            ptr += 4;
136
178
        }
145
187
        if (range != 0)
146
188
        {
147
189
            for (x = (int)param.min ; x <= (int)param.max ; ++x)
 
190
            {
148
191
                param.lut[x] = (unsigned short)((segments-1) * (x - param.min) / range);
 
192
            }
149
193
        }
150
194
        else
151
195
        {
153
197
        }
154
198
    }
155
199
 
156
 
    uchar* data = m_orgImage.bits(); 
 
200
    uchar* data = m_orgImage.bits();
157
201
    int w       = m_orgImage.width();
158
202
    int h       = m_orgImage.height();
159
203
    uint size   = w*h;
178
222
            ptr += 4;
179
223
 
180
224
            progress = (int)(((double)i * 100.0) / size);
 
225
 
181
226
            if ( progress%5 == 0 )
 
227
            {
182
228
                postProgress( progress );
 
229
            }
183
230
        }
184
231
    }
185
232
    else                    // 16 bits image.
200
247
            ptr += 4;
201
248
 
202
249
            progress = (int)(((double)i * 100.0) / size);
 
250
 
203
251
            if ( progress%5 == 0 )
 
252
            {
204
253
                postProgress( progress );
 
254
            }
205
255
        }
206
256
    }
207
257