author | sandman <sandman> | 2002-07-01 23:38:26 (UTC) |
---|---|---|
committer | sandman <sandman> | 2002-07-01 23:38:26 (UTC) |
commit | 7191d788415f190680c8a699b2b7bb88ddf28917 (patch) (unidiff) | |
tree | 4b1f4c3327d7265da5552d332261ff6c4bf773ec | |
parent | 667202e7e7a39ed6cbe09857c567c4acd246ab0e (diff) | |
download | opie-7191d788415f190680c8a699b2b7bb88ddf28917.zip opie-7191d788415f190680c8a699b2b7bb88ddf28917.tar.gz opie-7191d788415f190680c8a699b2b7bb88ddf28917.tar.bz2 |
- fixed some "unused variable" warnings from the KDE code
- replaced sqrt() calls QPE's qSqrt()
-rw-r--r-- | noncore/styles/theme/ogfxeffect.cpp | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/noncore/styles/theme/ogfxeffect.cpp b/noncore/styles/theme/ogfxeffect.cpp index a991728..55f3c1f 100644 --- a/noncore/styles/theme/ogfxeffect.cpp +++ b/noncore/styles/theme/ogfxeffect.cpp | |||
@@ -1,324 +1,324 @@ | |||
1 | /* This file is part of the KDE libraries | 1 | /* This file is part of the KDE libraries |
2 | Copyright (C) 1998, 1999 Christian Tibirna <ctibirna@total.net> | 2 | Copyright (C) 1998, 1999 Christian Tibirna <ctibirna@total.net> |
3 | (C) 1998, 1999 Daniel M. Duley <mosfet@kde.org> | 3 | (C) 1998, 1999 Daniel M. Duley <mosfet@kde.org> |
4 | (C) 1998, 1999 Dirk A. Mueller <mueller@kde.org> | 4 | (C) 1998, 1999 Dirk A. Mueller <mueller@kde.org> |
5 | 5 | ||
6 | */ | 6 | */ |
7 | 7 | ||
8 | // $Id$ | 8 | // $Id$ |
9 | 9 | ||
10 | #include <qimage.h> | 10 | #include <qimage.h> |
11 | #include <qpainter.h> | 11 | #include <qpainter.h> |
12 | 12 | ||
13 | #include <qpe/qmath.h> | ||
14 | |||
13 | #include "ogfxeffect.h" | 15 | #include "ogfxeffect.h" |
14 | 16 | ||
15 | 17 | ||
16 | //====================================================================== | 18 | //====================================================================== |
17 | // | 19 | // |
18 | // Gradient effects | 20 | // Gradient effects |
19 | // | 21 | // |
20 | //====================================================================== | 22 | //====================================================================== |
21 | 23 | ||
22 | 24 | ||
23 | QPixmap& OGfxEffect::gradient(QPixmap &pixmap, const QColor &ca, | 25 | QPixmap& OGfxEffect::gradient(QPixmap &pixmap, const QColor &ca, |
24 | const QColor &cb, GradientType eff, int ncols) | 26 | const QColor &cb, GradientType eff, int /*ncols*/) |
25 | { | 27 | { |
26 | if(pixmap.depth() > 8 && | 28 | if(pixmap.depth() > 8 && |
27 | (eff == VerticalGradient || eff == HorizontalGradient)) { | 29 | (eff == VerticalGradient || eff == HorizontalGradient)) { |
28 | 30 | ||
29 | int rDiff, gDiff, bDiff; | 31 | int rDiff, gDiff, bDiff; |
30 | int rca, gca, bca /*, rcb, gcb, bcb*/; | 32 | int rca, gca, bca /*, rcb, gcb, bcb*/; |
31 | 33 | ||
32 | register int x, y; | 34 | register int x, y; |
33 | 35 | ||
34 | rDiff = (/*rcb = */ cb.red()) - (rca = ca.red()); | 36 | rDiff = (/*rcb = */ cb.red()) - (rca = ca.red()); |
35 | gDiff = (/*gcb = */ cb.green()) - (gca = ca.green()); | 37 | gDiff = (/*gcb = */ cb.green()) - (gca = ca.green()); |
36 | bDiff = (/*bcb = */ cb.blue()) - (bca = ca.blue()); | 38 | bDiff = (/*bcb = */ cb.blue()) - (bca = ca.blue()); |
37 | 39 | ||
38 | register int rl = rca << 16; | 40 | register int rl = rca << 16; |
39 | register int gl = gca << 16; | 41 | register int gl = gca << 16; |
40 | register int bl = bca << 16; | 42 | register int bl = bca << 16; |
41 | 43 | ||
42 | int rcdelta = ((1<<16) / (eff == VerticalGradient ? pixmap.height() : pixmap.width())) * rDiff; | 44 | int rcdelta = ((1<<16) / (eff == VerticalGradient ? pixmap.height() : pixmap.width())) * rDiff; |
43 | int gcdelta = ((1<<16) / (eff == VerticalGradient ? pixmap.height() : pixmap.width())) * gDiff; | 45 | int gcdelta = ((1<<16) / (eff == VerticalGradient ? pixmap.height() : pixmap.width())) * gDiff; |
44 | int bcdelta = ((1<<16) / (eff == VerticalGradient ? pixmap.height() : pixmap.width())) * bDiff; | 46 | int bcdelta = ((1<<16) / (eff == VerticalGradient ? pixmap.height() : pixmap.width())) * bDiff; |
45 | 47 | ||
46 | QPainter p(&pixmap); | 48 | QPainter p(&pixmap); |
47 | 49 | ||
48 | // these for-loops could be merged, but the if's in the inner loop | 50 | // these for-loops could be merged, but the if's in the inner loop |
49 | // would make it slow | 51 | // would make it slow |
50 | switch(eff) { | 52 | switch(eff) { |
51 | case VerticalGradient: | 53 | case VerticalGradient: |
52 | for ( y = 0; y < pixmap.height(); y++ ) { | 54 | for ( y = 0; y < pixmap.height(); y++ ) { |
53 | rl += rcdelta; | 55 | rl += rcdelta; |
54 | gl += gcdelta; | 56 | gl += gcdelta; |
55 | bl += bcdelta; | 57 | bl += bcdelta; |
56 | 58 | ||
57 | p.setPen(QColor(rl>>16, gl>>16, bl>>16)); | 59 | p.setPen(QColor(rl>>16, gl>>16, bl>>16)); |
58 | p.drawLine(0, y, pixmap.width()-1, y); | 60 | p.drawLine(0, y, pixmap.width()-1, y); |
59 | } | 61 | } |
60 | break; | 62 | break; |
61 | case HorizontalGradient: | 63 | case HorizontalGradient: |
62 | for( x = 0; x < pixmap.width(); x++) { | 64 | for( x = 0; x < pixmap.width(); x++) { |
63 | rl += rcdelta; | 65 | rl += rcdelta; |
64 | gl += gcdelta; | 66 | gl += gcdelta; |
65 | bl += bcdelta; | 67 | bl += bcdelta; |
66 | 68 | ||
67 | p.setPen(QColor(rl>>16, gl>>16, bl>>16)); | 69 | p.setPen(QColor(rl>>16, gl>>16, bl>>16)); |
68 | p.drawLine(x, 0, x, pixmap.height()-1); | 70 | p.drawLine(x, 0, x, pixmap.height()-1); |
69 | } | 71 | } |
70 | break; | 72 | break; |
71 | default: | 73 | default: |
72 | ; | 74 | ; |
73 | } | 75 | } |
74 | } | 76 | } |
75 | else { | 77 | else { |
76 | // QImage image = OGfxEffect::gradient(pixmap.size(), ca, cb, | 78 | // QImage image = OGfxEffect::gradient(pixmap.size(), ca, cb, |
77 | // (OGfxEffect::GradientType) eff, ncols); | 79 | // (OGfxEffect::GradientType) eff, ncols); |
78 | // pixmap.convertFromImage(image); | 80 | // pixmap.convertFromImage(image); |
79 | } | 81 | } |
80 | 82 | ||
81 | return pixmap; | 83 | return pixmap; |
82 | } | 84 | } |
83 | 85 | ||
84 | 86 | ||
85 | //====================================================================== | 87 | //====================================================================== |
86 | // | 88 | // |
87 | // Blend effects | 89 | // Blend effects |
88 | // | 90 | // |
89 | //====================================================================== | 91 | //====================================================================== |
90 | 92 | ||
91 | 93 | ||
92 | QPixmap& OGfxEffect::blend(QPixmap &pixmap, float initial_intensity, | 94 | QPixmap& OGfxEffect::blend(QPixmap &pixmap, float initial_intensity, |
93 | const QColor &bgnd, GradientType eff, | 95 | const QColor &bgnd, GradientType eff, |
94 | bool anti_dir, int ncols) | 96 | bool anti_dir, int /*ncols*/) |
95 | { | 97 | { |
96 | QImage image = pixmap.convertToImage(); | 98 | QImage image = pixmap.convertToImage(); |
97 | OGfxEffect::blend(image, initial_intensity, bgnd, eff, anti_dir); | 99 | OGfxEffect::blend(image, initial_intensity, bgnd, eff, anti_dir); |
98 | 100 | ||
99 | unsigned int tmp; | ||
100 | |||
101 | if ( pixmap. depth ( ) <= 8 ) | 101 | if ( pixmap. depth ( ) <= 8 ) |
102 | image. convertDepth ( pixmap. depth ( )); | 102 | image. convertDepth ( pixmap. depth ( )); |
103 | 103 | ||
104 | pixmap.convertFromImage(image); | 104 | pixmap.convertFromImage(image); |
105 | 105 | ||
106 | return pixmap; | 106 | return pixmap; |
107 | } | 107 | } |
108 | 108 | ||
109 | 109 | ||
110 | QImage& OGfxEffect::blend(QImage &image, float initial_intensity, | 110 | QImage& OGfxEffect::blend(QImage &image, float initial_intensity, |
111 | const QColor &bgnd, GradientType eff, | 111 | const QColor &bgnd, GradientType eff, |
112 | bool anti_dir) | 112 | bool anti_dir) |
113 | { | 113 | { |
114 | if (image.width() == 0 || image.height() == 0) { | 114 | if (image.width() == 0 || image.height() == 0) { |
115 | qDebug ( "Invalid image\n" ); | 115 | qDebug ( "Invalid image\n" ); |
116 | return image; | 116 | return image; |
117 | } | 117 | } |
118 | 118 | ||
119 | int r_bgnd = bgnd.red(), g_bgnd = bgnd.green(), b_bgnd = bgnd.blue(); | 119 | int r_bgnd = bgnd.red(), g_bgnd = bgnd.green(), b_bgnd = bgnd.blue(); |
120 | int r, g, b; | 120 | int r, g, b; |
121 | int ind; | 121 | int ind; |
122 | 122 | ||
123 | unsigned int xi, xf, yi, yf; | 123 | unsigned int xi, xf, yi, yf; |
124 | unsigned int a; | 124 | unsigned int a; |
125 | 125 | ||
126 | // check the boundaries of the initial intesity param | 126 | // check the boundaries of the initial intesity param |
127 | float unaffected = 1; | 127 | float unaffected = 1; |
128 | if (initial_intensity > 1) initial_intensity = 1; | 128 | if (initial_intensity > 1) initial_intensity = 1; |
129 | if (initial_intensity < -1) initial_intensity = -1; | 129 | if (initial_intensity < -1) initial_intensity = -1; |
130 | if (initial_intensity < 0) { | 130 | if (initial_intensity < 0) { |
131 | unaffected = 1. + initial_intensity; | 131 | unaffected = 1. + initial_intensity; |
132 | initial_intensity = 0; | 132 | initial_intensity = 0; |
133 | } | 133 | } |
134 | 134 | ||
135 | 135 | ||
136 | float intensity = initial_intensity; | 136 | float intensity = initial_intensity; |
137 | float var = 1. - initial_intensity; | 137 | float var = 1. - initial_intensity; |
138 | 138 | ||
139 | if (anti_dir) { | 139 | if (anti_dir) { |
140 | initial_intensity = intensity = 1.; | 140 | initial_intensity = intensity = 1.; |
141 | var = -var; | 141 | var = -var; |
142 | } | 142 | } |
143 | 143 | ||
144 | register int x, y; | 144 | register int x, y; |
145 | 145 | ||
146 | unsigned int *data = (unsigned int *)image.bits(); | 146 | unsigned int *data = (unsigned int *)image.bits(); |
147 | 147 | ||
148 | if( eff == VerticalGradient || eff == HorizontalGradient ) { | 148 | if( eff == VerticalGradient || eff == HorizontalGradient ) { |
149 | 149 | ||
150 | // set the image domain to apply the effect to | 150 | // set the image domain to apply the effect to |
151 | xi = 0, xf = image.width(); | 151 | xi = 0, xf = image.width(); |
152 | yi = 0, yf = image.height(); | 152 | yi = 0, yf = image.height(); |
153 | if (eff == VerticalGradient) { | 153 | if (eff == VerticalGradient) { |
154 | if (anti_dir) yf = (int)(image.height() * unaffected); | 154 | if (anti_dir) yf = (int)(image.height() * unaffected); |
155 | else yi = (int)(image.height() * (1 - unaffected)); | 155 | else yi = (int)(image.height() * (1 - unaffected)); |
156 | } | 156 | } |
157 | else { | 157 | else { |
158 | if (anti_dir) xf = (int)(image.width() * unaffected); | 158 | if (anti_dir) xf = (int)(image.width() * unaffected); |
159 | else xi = (int)(image.height() * (1 - unaffected)); | 159 | else xi = (int)(image.height() * (1 - unaffected)); |
160 | } | 160 | } |
161 | 161 | ||
162 | var /= (eff == VerticalGradient?yf-yi:xf-xi); | 162 | var /= (eff == VerticalGradient?yf-yi:xf-xi); |
163 | 163 | ||
164 | for (y = yi; y < (int)yf; y++) { | 164 | for (y = yi; y < (int)yf; y++) { |
165 | intensity = eff == VerticalGradient? intensity + var : | 165 | intensity = eff == VerticalGradient? intensity + var : |
166 | initial_intensity; | 166 | initial_intensity; |
167 | for (x = xi; x < (int)xf ; x++) { | 167 | for (x = xi; x < (int)xf ; x++) { |
168 | if (eff == HorizontalGradient) intensity += var; | 168 | if (eff == HorizontalGradient) intensity += var; |
169 | ind = x + image.width() * y ; | 169 | ind = x + image.width() * y ; |
170 | r = qRed (data[ind]) + (int)(intensity * | 170 | r = qRed (data[ind]) + (int)(intensity * |
171 | (r_bgnd - qRed (data[ind]))); | 171 | (r_bgnd - qRed (data[ind]))); |
172 | g = qGreen(data[ind]) + (int)(intensity * | 172 | g = qGreen(data[ind]) + (int)(intensity * |
173 | (g_bgnd - qGreen(data[ind]))); | 173 | (g_bgnd - qGreen(data[ind]))); |
174 | b = qBlue (data[ind]) + (int)(intensity * | 174 | b = qBlue (data[ind]) + (int)(intensity * |
175 | (b_bgnd - qBlue (data[ind]))); | 175 | (b_bgnd - qBlue (data[ind]))); |
176 | if (r > 255) r = 255; if (r < 0 ) r = 0; | 176 | if (r > 255) r = 255; if (r < 0 ) r = 0; |
177 | if (g > 255) g = 255; if (g < 0 ) g = 0; | 177 | if (g > 255) g = 255; if (g < 0 ) g = 0; |
178 | if (b > 255) b = 255; if (b < 0 ) b = 0; | 178 | if (b > 255) b = 255; if (b < 0 ) b = 0; |
179 | a = qAlpha(data[ind]); | 179 | a = qAlpha(data[ind]); |
180 | data[ind] = qRgba(r, g, b, a); | 180 | data[ind] = qRgba(r, g, b, a); |
181 | } | 181 | } |
182 | } | 182 | } |
183 | } | 183 | } |
184 | else if (eff == DiagonalGradient || eff == CrossDiagonalGradient) { | 184 | else if (eff == DiagonalGradient || eff == CrossDiagonalGradient) { |
185 | float xvar = var / 2 / image.width(); // / unaffected; | 185 | float xvar = var / 2 / image.width(); // / unaffected; |
186 | float yvar = var / 2 / image.height(); // / unaffected; | 186 | float yvar = var / 2 / image.height(); // / unaffected; |
187 | float tmp; | 187 | float tmp; |
188 | 188 | ||
189 | for (x = 0; x < image.width() ; x++) { | 189 | for (x = 0; x < image.width() ; x++) { |
190 | tmp = xvar * (eff == DiagonalGradient? x : image.width()-x-1); | 190 | tmp = xvar * (eff == DiagonalGradient? x : image.width()-x-1); |
191 | for (y = 0; y < image.height() ; y++) { | 191 | for (y = 0; y < image.height() ; y++) { |
192 | intensity = initial_intensity + tmp + yvar * y; | 192 | intensity = initial_intensity + tmp + yvar * y; |
193 | ind = x + image.width() * y ; | 193 | ind = x + image.width() * y ; |
194 | r = qRed (data[ind]) + (int)(intensity * | 194 | r = qRed (data[ind]) + (int)(intensity * |
195 | (r_bgnd - qRed (data[ind]))); | 195 | (r_bgnd - qRed (data[ind]))); |
196 | g = qGreen(data[ind]) + (int)(intensity * | 196 | g = qGreen(data[ind]) + (int)(intensity * |
197 | (g_bgnd - qGreen(data[ind]))); | 197 | (g_bgnd - qGreen(data[ind]))); |
198 | b = qBlue (data[ind]) + (int)(intensity * | 198 | b = qBlue (data[ind]) + (int)(intensity * |
199 | (b_bgnd - qBlue (data[ind]))); | 199 | (b_bgnd - qBlue (data[ind]))); |
200 | if (r > 255) r = 255; if (r < 0 ) r = 0; | 200 | if (r > 255) r = 255; if (r < 0 ) r = 0; |
201 | if (g > 255) g = 255; if (g < 0 ) g = 0; | 201 | if (g > 255) g = 255; if (g < 0 ) g = 0; |
202 | if (b > 255) b = 255; if (b < 0 ) b = 0; | 202 | if (b > 255) b = 255; if (b < 0 ) b = 0; |
203 | a = qAlpha(data[ind]); | 203 | a = qAlpha(data[ind]); |
204 | data[ind] = qRgba(r, g, b, a); | 204 | data[ind] = qRgba(r, g, b, a); |
205 | } | 205 | } |
206 | } | 206 | } |
207 | } | 207 | } |
208 | 208 | ||
209 | else if (eff == RectangleGradient || eff == EllipticGradient) { | 209 | else if (eff == RectangleGradient || eff == EllipticGradient) { |
210 | float xvar; | 210 | float xvar; |
211 | float yvar; | 211 | float yvar; |
212 | 212 | ||
213 | for (x = 0; x < image.width() / 2 + image.width() % 2; x++) { | 213 | for (x = 0; x < image.width() / 2 + image.width() % 2; x++) { |
214 | xvar = var / image.width() * (image.width() - x*2/unaffected-1); | 214 | xvar = var / image.width() * (image.width() - x*2/unaffected-1); |
215 | for (y = 0; y < image.height() / 2 + image.height() % 2; y++) { | 215 | for (y = 0; y < image.height() / 2 + image.height() % 2; y++) { |
216 | yvar = var / image.height() * (image.height() - y*2/unaffected -1); | 216 | yvar = var / image.height() * (image.height() - y*2/unaffected -1); |
217 | 217 | ||
218 | if (eff == RectangleGradient) | 218 | if (eff == RectangleGradient) |
219 | intensity = initial_intensity + QMAX(xvar, yvar); | 219 | intensity = initial_intensity + QMAX(xvar, yvar); |
220 | else | 220 | else |
221 | intensity = initial_intensity + sqrt(xvar * xvar + yvar * yvar); | 221 | intensity = initial_intensity + qSqrt(xvar * xvar + yvar * yvar); |
222 | if (intensity > 1) intensity = 1; | 222 | if (intensity > 1) intensity = 1; |
223 | if (intensity < 0) intensity = 0; | 223 | if (intensity < 0) intensity = 0; |
224 | 224 | ||
225 | //NW | 225 | //NW |
226 | ind = x + image.width() * y ; | 226 | ind = x + image.width() * y ; |
227 | r = qRed (data[ind]) + (int)(intensity * | 227 | r = qRed (data[ind]) + (int)(intensity * |
228 | (r_bgnd - qRed (data[ind]))); | 228 | (r_bgnd - qRed (data[ind]))); |
229 | g = qGreen(data[ind]) + (int)(intensity * | 229 | g = qGreen(data[ind]) + (int)(intensity * |
230 | (g_bgnd - qGreen(data[ind]))); | 230 | (g_bgnd - qGreen(data[ind]))); |
231 | b = qBlue (data[ind]) + (int)(intensity * | 231 | b = qBlue (data[ind]) + (int)(intensity * |
232 | (b_bgnd - qBlue (data[ind]))); | 232 | (b_bgnd - qBlue (data[ind]))); |
233 | if (r > 255) r = 255; if (r < 0 ) r = 0; | 233 | if (r > 255) r = 255; if (r < 0 ) r = 0; |
234 | if (g > 255) g = 255; if (g < 0 ) g = 0; | 234 | if (g > 255) g = 255; if (g < 0 ) g = 0; |
235 | if (b > 255) b = 255; if (b < 0 ) b = 0; | 235 | if (b > 255) b = 255; if (b < 0 ) b = 0; |
236 | a = qAlpha(data[ind]); | 236 | a = qAlpha(data[ind]); |
237 | data[ind] = qRgba(r, g, b, a); | 237 | data[ind] = qRgba(r, g, b, a); |
238 | 238 | ||
239 | //NE | 239 | //NE |
240 | ind = image.width() - x - 1 + image.width() * y ; | 240 | ind = image.width() - x - 1 + image.width() * y ; |
241 | r = qRed (data[ind]) + (int)(intensity * | 241 | r = qRed (data[ind]) + (int)(intensity * |
242 | (r_bgnd - qRed (data[ind]))); | 242 | (r_bgnd - qRed (data[ind]))); |
243 | g = qGreen(data[ind]) + (int)(intensity * | 243 | g = qGreen(data[ind]) + (int)(intensity * |
244 | (g_bgnd - qGreen(data[ind]))); | 244 | (g_bgnd - qGreen(data[ind]))); |
245 | b = qBlue (data[ind]) + (int)(intensity * | 245 | b = qBlue (data[ind]) + (int)(intensity * |
246 | (b_bgnd - qBlue (data[ind]))); | 246 | (b_bgnd - qBlue (data[ind]))); |
247 | if (r > 255) r = 255; if (r < 0 ) r = 0; | 247 | if (r > 255) r = 255; if (r < 0 ) r = 0; |
248 | if (g > 255) g = 255; if (g < 0 ) g = 0; | 248 | if (g > 255) g = 255; if (g < 0 ) g = 0; |
249 | if (b > 255) b = 255; if (b < 0 ) b = 0; | 249 | if (b > 255) b = 255; if (b < 0 ) b = 0; |
250 | a = qAlpha(data[ind]); | 250 | a = qAlpha(data[ind]); |
251 | data[ind] = qRgba(r, g, b, a); | 251 | data[ind] = qRgba(r, g, b, a); |
252 | } | 252 | } |
253 | } | 253 | } |
254 | 254 | ||
255 | //CT loop is doubled because of stupid central row/column issue. | 255 | //CT loop is doubled because of stupid central row/column issue. |
256 | // other solution? | 256 | // other solution? |
257 | for (x = 0; x < image.width() / 2; x++) { | 257 | for (x = 0; x < image.width() / 2; x++) { |
258 | xvar = var / image.width() * (image.width() - x*2/unaffected-1); | 258 | xvar = var / image.width() * (image.width() - x*2/unaffected-1); |
259 | for (y = 0; y < image.height() / 2; y++) { | 259 | for (y = 0; y < image.height() / 2; y++) { |
260 | yvar = var / image.height() * (image.height() - y*2/unaffected -1); | 260 | yvar = var / image.height() * (image.height() - y*2/unaffected -1); |
261 | 261 | ||
262 | if (eff == RectangleGradient) | 262 | if (eff == RectangleGradient) |
263 | intensity = initial_intensity + QMAX(xvar, yvar); | 263 | intensity = initial_intensity + QMAX(xvar, yvar); |
264 | else | 264 | else |
265 | intensity = initial_intensity + sqrt(xvar * xvar + yvar * yvar); | 265 | intensity = initial_intensity + qSqrt(xvar * xvar + yvar * yvar); |
266 | if (intensity > 1) intensity = 1; | 266 | if (intensity > 1) intensity = 1; |
267 | if (intensity < 0) intensity = 0; | 267 | if (intensity < 0) intensity = 0; |
268 | 268 | ||
269 | //SW | 269 | //SW |
270 | ind = x + image.width() * (image.height() - y -1) ; | 270 | ind = x + image.width() * (image.height() - y -1) ; |
271 | r = qRed (data[ind]) + (int)(intensity * | 271 | r = qRed (data[ind]) + (int)(intensity * |
272 | (r_bgnd - qRed (data[ind]))); | 272 | (r_bgnd - qRed (data[ind]))); |
273 | g = qGreen(data[ind]) + (int)(intensity * | 273 | g = qGreen(data[ind]) + (int)(intensity * |
274 | (g_bgnd - qGreen(data[ind]))); | 274 | (g_bgnd - qGreen(data[ind]))); |
275 | b = qBlue (data[ind]) + (int)(intensity * | 275 | b = qBlue (data[ind]) + (int)(intensity * |
276 | (b_bgnd - qBlue (data[ind]))); | 276 | (b_bgnd - qBlue (data[ind]))); |
277 | if (r > 255) r = 255; if (r < 0 ) r = 0; | 277 | if (r > 255) r = 255; if (r < 0 ) r = 0; |
278 | if (g > 255) g = 255; if (g < 0 ) g = 0; | 278 | if (g > 255) g = 255; if (g < 0 ) g = 0; |
279 | if (b > 255) b = 255; if (b < 0 ) b = 0; | 279 | if (b > 255) b = 255; if (b < 0 ) b = 0; |
280 | a = qAlpha(data[ind]); | 280 | a = qAlpha(data[ind]); |
281 | data[ind] = qRgba(r, g, b, a); | 281 | data[ind] = qRgba(r, g, b, a); |
282 | 282 | ||
283 | //SE | 283 | //SE |
284 | ind = image.width()-x-1 + image.width() * (image.height() - y - 1) ; | 284 | ind = image.width()-x-1 + image.width() * (image.height() - y - 1) ; |
285 | r = qRed (data[ind]) + (int)(intensity * | 285 | r = qRed (data[ind]) + (int)(intensity * |
286 | (r_bgnd - qRed (data[ind]))); | 286 | (r_bgnd - qRed (data[ind]))); |
287 | g = qGreen(data[ind]) + (int)(intensity * | 287 | g = qGreen(data[ind]) + (int)(intensity * |
288 | (g_bgnd - qGreen(data[ind]))); | 288 | (g_bgnd - qGreen(data[ind]))); |
289 | b = qBlue (data[ind]) + (int)(intensity * | 289 | b = qBlue (data[ind]) + (int)(intensity * |
290 | (b_bgnd - qBlue (data[ind]))); | 290 | (b_bgnd - qBlue (data[ind]))); |
291 | if (r > 255) r = 255; if (r < 0 ) r = 0; | 291 | if (r > 255) r = 255; if (r < 0 ) r = 0; |
292 | if (g > 255) g = 255; if (g < 0 ) g = 0; | 292 | if (g > 255) g = 255; if (g < 0 ) g = 0; |
293 | if (b > 255) b = 255; if (b < 0 ) b = 0; | 293 | if (b > 255) b = 255; if (b < 0 ) b = 0; |
294 | a = qAlpha(data[ind]); | 294 | a = qAlpha(data[ind]); |
295 | data[ind] = qRgba(r, g, b, a); | 295 | data[ind] = qRgba(r, g, b, a); |
296 | } | 296 | } |
297 | } | 297 | } |
298 | } | 298 | } |
299 | 299 | ||
300 | else | 300 | else |
301 | qDebug ( "not implemented\n" ); | 301 | qDebug ( "not implemented\n" ); |
302 | 302 | ||
303 | return image; | 303 | return image; |
304 | } | 304 | } |
305 | 305 | ||
306 | #if 0 | 306 | #if 0 |
307 | // Not very efficient as we create a third big image... | 307 | // Not very efficient as we create a third big image... |
308 | // | 308 | // |
309 | QImage& KQGfxEffect::blend(QImage &image1, QImage &image2, | 309 | QImage& KQGfxEffect::blend(QImage &image1, QImage &image2, |
310 | GradientType gt, int xf, int yf) | 310 | GradientType gt, int xf, int yf) |
311 | { | 311 | { |
312 | if (image1.width() == 0 || image1.height() == 0 || | 312 | if (image1.width() == 0 || image1.height() == 0 || |
313 | image2.width() == 0 || image2.height() == 0) | 313 | image2.width() == 0 || image2.height() == 0) |
314 | return image1; | 314 | return image1; |
315 | 315 | ||
316 | QImage image3; | 316 | QImage image3; |
317 | 317 | ||
318 | image3 = KQGfxEffect::unbalancedGradient(image1.size(), | 318 | image3 = KQGfxEffect::unbalancedGradient(image1.size(), |
319 | QColor(0,0,0), QColor(255,255,255), | 319 | QColor(0,0,0), QColor(255,255,255), |
320 | gt, xf, yf, 0); | 320 | gt, xf, yf, 0); |
321 | 321 | ||
322 | return blend(image1,image2,image3, Red); // Channel to use is arbitrary | 322 | return blend(image1,image2,image3, Red); // Channel to use is arbitrary |
323 | } | 323 | } |
324 | #endif | 324 | #endif |