Diffstat (limited to 'libopie2/opieui/opixmapeffect.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | libopie2/opieui/opixmapeffect.cpp | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/libopie2/opieui/opixmapeffect.cpp b/libopie2/opieui/opixmapeffect.cpp index 05f851d..794c7b2 100644 --- a/libopie2/opieui/opixmapeffect.cpp +++ b/libopie2/opieui/opixmapeffect.cpp | |||
@@ -1,67 +1,69 @@ | |||
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 | /* QT */ | 10 | /* QT */ |
11 | 11 | ||
12 | #include <qimage.h> | 12 | #include <qimage.h> |
13 | #include <qpainter.h> | 13 | #include <qpainter.h> |
14 | 14 | ||
15 | /* OPIE */ | 15 | /* OPIE */ |
16 | 16 | ||
17 | #include <opie2/opixmapeffect.h> | 17 | #include <opie2/opixmapeffect.h> |
18 | #include <opie2/oimageeffect.h> | 18 | #include <opie2/oimageeffect.h> |
19 | 19 | ||
20 | |||
21 | using namespace Opie::Ui; | ||
20 | //====================================================================== | 22 | //====================================================================== |
21 | // | 23 | // |
22 | // Gradient effects | 24 | // Gradient effects |
23 | // | 25 | // |
24 | //====================================================================== | 26 | //====================================================================== |
25 | 27 | ||
26 | 28 | ||
27 | OPixmap& OPixmapEffect::gradient(OPixmap &pixmap, const QColor &ca, | 29 | OPixmap& OPixmapEffect::gradient(OPixmap &pixmap, const QColor &ca, |
28 | const QColor &cb, GradientType eff, int ncols) | 30 | const QColor &cb, GradientType eff, int ncols) |
29 | { | 31 | { |
30 | if(pixmap.depth() > 8 && | 32 | if(pixmap.depth() > 8 && |
31 | (eff == VerticalGradient || eff == HorizontalGradient)) { | 33 | (eff == VerticalGradient || eff == HorizontalGradient)) { |
32 | 34 | ||
33 | int rDiff, gDiff, bDiff; | 35 | int rDiff, gDiff, bDiff; |
34 | int rca, gca, bca /*, rcb, gcb, bcb*/; | 36 | int rca, gca, bca /*, rcb, gcb, bcb*/; |
35 | 37 | ||
36 | register int x, y; | 38 | register int x, y; |
37 | 39 | ||
38 | rDiff = (/*rcb = */ cb.red()) - (rca = ca.red()); | 40 | rDiff = (/*rcb = */ cb.red()) - (rca = ca.red()); |
39 | gDiff = (/*gcb = */ cb.green()) - (gca = ca.green()); | 41 | gDiff = (/*gcb = */ cb.green()) - (gca = ca.green()); |
40 | bDiff = (/*bcb = */ cb.blue()) - (bca = ca.blue()); | 42 | bDiff = (/*bcb = */ cb.blue()) - (bca = ca.blue()); |
41 | 43 | ||
42 | register int rl = rca << 16; | 44 | register int rl = rca << 16; |
43 | register int gl = gca << 16; | 45 | register int gl = gca << 16; |
44 | register int bl = bca << 16; | 46 | register int bl = bca << 16; |
45 | 47 | ||
46 | int rcdelta = ((1<<16) / (eff == VerticalGradient ? pixmap.height() : pixmap.width())) * rDiff; | 48 | int rcdelta = ((1<<16) / (eff == VerticalGradient ? pixmap.height() : pixmap.width())) * rDiff; |
47 | int gcdelta = ((1<<16) / (eff == VerticalGradient ? pixmap.height() : pixmap.width())) * gDiff; | 49 | int gcdelta = ((1<<16) / (eff == VerticalGradient ? pixmap.height() : pixmap.width())) * gDiff; |
48 | int bcdelta = ((1<<16) / (eff == VerticalGradient ? pixmap.height() : pixmap.width())) * bDiff; | 50 | int bcdelta = ((1<<16) / (eff == VerticalGradient ? pixmap.height() : pixmap.width())) * bDiff; |
49 | 51 | ||
50 | QPainter p(&pixmap); | 52 | QPainter p(&pixmap); |
51 | 53 | ||
52 | // these for-loops could be merged, but the if's in the inner loop | 54 | // these for-loops could be merged, but the if's in the inner loop |
53 | // would make it slow | 55 | // would make it slow |
54 | switch(eff) { | 56 | switch(eff) { |
55 | case VerticalGradient: | 57 | case VerticalGradient: |
56 | for ( y = 0; y < pixmap.height(); y++ ) { | 58 | for ( y = 0; y < pixmap.height(); y++ ) { |
57 | rl += rcdelta; | 59 | rl += rcdelta; |
58 | gl += gcdelta; | 60 | gl += gcdelta; |
59 | bl += bcdelta; | 61 | bl += bcdelta; |
60 | 62 | ||
61 | p.setPen(QColor(rl>>16, gl>>16, bl>>16)); | 63 | p.setPen(QColor(rl>>16, gl>>16, bl>>16)); |
62 | p.drawLine(0, y, pixmap.width()-1, y); | 64 | p.drawLine(0, y, pixmap.width()-1, y); |
63 | } | 65 | } |
64 | break; | 66 | break; |
65 | case HorizontalGradient: | 67 | case HorizontalGradient: |
66 | for( x = 0; x < pixmap.width(); x++) { | 68 | for( x = 0; x < pixmap.width(); x++) { |
67 | rl += rcdelta; | 69 | rl += rcdelta; |