~ubuntu-branches/ubuntu/intrepid/digikam/intrepid

« back to all changes in this revision

Viewing changes to digikam/libs/dimg/filters/bcgmodifier.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Mark Purcell
  • Date: 2008-07-17 20:25:39 UTC
  • mfrom: (1.2.15 upstream) (3.1.2 lenny)
  • Revision ID: james.westby@ubuntu.com-20080717202539-6n7dtirbkoo7qvhd
Tags: 2:0.9.4-1
* New upstream release
  - digiKam 0.9.4 Release Plan (KDE3) ~ 13 July 08 (Closes: #490144)
* DEB_CONFIGURE_EXTRA_FLAGS := --without-included-sqlite3
* Debhelper compatibility level V7
* Install pixmaps in debian/*.install
* Add debian/digikam.lintian-overrides

Show diffs side-by-side

added added

removed removed

Lines of Context:
7
7
 * Description : a Brightness/Contrast/Gamma image filter.
8
8
 * 
9
9
 * Copyright (C) 2005 by Renchi Raju <renchi@pooh.tam.uiuc.edu>
10
 
 * Copyright (C) 2005-2007 by Gilles Caulier <caulier dot gilles at gmail dot com> 
 
10
 * Copyright (C) 2005-2008 by Gilles Caulier <caulier dot gilles at gmail dot com> 
11
11
 *
12
12
 * This program is free software; you can redistribute it
13
13
 * and/or modify it under the terms of the GNU General
50
50
 
51
51
    bool modified;
52
52
 
53
 
    int  channel;      
 
53
    int  channel;
54
54
    int  map16[65536];
55
55
    int  map[256];
56
56
};
57
57
 
58
58
BCGModifier::BCGModifier()
59
59
{
60
 
    d = new BCGModifierPriv;    
 
60
    d = new BCGModifierPriv;
61
61
    reset();
62
62
}
63
63
 
89
89
    if (!d->modified || image.isNull())
90
90
        return;
91
91
 
92
 
    uint size = image.numPixels();
93
 
 
94
 
    if (!image.sixteenBit())                    // 8 bits image.
 
92
    applyBCG(image.bits(), image.width(), image.height(), image.sixteenBit());
 
93
}
 
94
 
 
95
void BCGModifier::applyBCG(uchar *bits, uint width, uint height, bool sixteenBits)
 
96
{
 
97
    if (!d->modified || !bits)
 
98
        return;
 
99
 
 
100
    uint size = width*height;
 
101
 
 
102
    if (!sixteenBits)                    // 8 bits image.
95
103
    {
96
 
        uchar* data = (uchar*) image.bits();
 
104
        uchar* data = bits;
97
105
 
98
106
        for (uint i=0; i<size; i++)
99
107
        {
123
131
    }
124
132
    else                                        // 16 bits image.
125
133
    {
126
 
        ushort* data = (ushort*) image.bits();
 
134
        ushort* data = (ushort*)bits;
127
135
 
128
136
        for (uint i=0; i<size; i++)
129
137
        {
167
175
 
168
176
    for (int i=0; i<256; i++)
169
177
        d->map[i] = lround(pow(((double)d->map[i] / 255.0), (1.0 / val)) * 255.0);
170
 
    
 
178
 
171
179
    d->modified = true;
172
180
}
173
181
 
179
187
        d->map16[i] = d->map16[i] + val1;
180
188
 
181
189
    val1 = lround(val * 255);
182
 
    
 
190
 
183
191
    for (int i = 0; i < 256; i++)
184
192
        d->map[i] = d->map[i] + val1;
185
 
    
 
193
 
186
194
    d->modified = true;
187
195
}
188
196
 
193
201
 
194
202
    for (int i = 0; i < 256; i++)
195
203
        d->map[i] = lround((d->map[i] - 127) * val) + 127;
196
 
    
 
204
 
197
205
    d->modified = true;
198
206
}
199
207