summaryrefslogtreecommitdiff
path: root/noncore
Unidiff
Diffstat (limited to 'noncore') (more/less context) (show whitespace changes)
-rw-r--r--noncore/styles/theme/ogfxeffect.cpp12
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,36 +1,38 @@
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
23QPixmap& OGfxEffect::gradient(QPixmap &pixmap, const QColor &ca, 25QPixmap& 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());
@@ -82,31 +84,29 @@ QPixmap& OGfxEffect::gradient(QPixmap &pixmap, const QColor &ca,
82} 84}
83 85
84 86
85//====================================================================== 87//======================================================================
86// 88//
87// Blend effects 89// Blend effects
88// 90//
89//====================================================================== 91//======================================================================
90 92
91 93
92QPixmap& OGfxEffect::blend(QPixmap &pixmap, float initial_intensity, 94QPixmap& 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
110QImage& OGfxEffect::blend(QImage &image, float initial_intensity, 110QImage& 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)
@@ -209,25 +209,25 @@ QImage& OGfxEffect::blend(QImage &image, float initial_intensity,
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;
@@ -253,25 +253,25 @@ QImage& OGfxEffect::blend(QImage &image, float initial_intensity,
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;