71{
72 QPixmap checker(8, 8);
74 p.fillRect(0, 0, 4, 4, Qt::lightGray);
75 p.fillRect(4, 0, 4, 4, Qt::darkGray);
76 p.fillRect(0, 4, 4, 4, Qt::darkGray);
77 p.fillRect(4, 4, 4, 4, Qt::lightGray);
79 QRect contentsRect_(contentsRect());
80 painter->fillRect(contentsRect_, QBrush(checker));
81
82 if( !
d->upToDate ||
d->pixmap.isNull() ||
d->pixmap.width() != contentsRect_.width()
83 ||
d->pixmap.height() != contentsRect_.height() )
84 {
86 QColor color;
87
88 const quint8 *colors[2];
89 colors[0] =
d->minColor.data();
90 colors[1] =
d->maxColor.data();
91
93 Q_ASSERT(mixOp);
94 QImage image(contentsRect_.width(), contentsRect_.height(), QImage::Format_ARGB32 );
95
96 if( orientation() == Qt::Horizontal ) {
97 for (
int x = 0;
x < contentsRect_.width();
x++) {
98
99 qreal t =
static_cast<qreal
>(
x) / (contentsRect_.width() - 1);
100
101 qint16 colorWeights[2];
102 colorWeights[0] = static_cast<quint8>((1.0 - t) * 255 + 0.5);
103 colorWeights[1] = 255 - colorWeights[0];
104
106
107 if (
d->displayRenderer) {
108 color =
d->displayRenderer->toQColor(c);
109 }
110 else {
112 }
113
114 for (
int y = 0;
y < contentsRect_.height();
y++)
115 image.setPixel(x, y, color.rgba());
116 }
117 }
118 else {
119 for (
int y = 0;
y < contentsRect_.height();
y++) {
120
121 qreal t =
static_cast<qreal
>(
y) / (contentsRect_.height() - 1);
122
123 qint16 colorWeights[2];
124 colorWeights[0] = static_cast<quint8>((t) * 255 + 0.5);
125 colorWeights[1] = 255 - colorWeights[0];
126
128
129 if (
d->displayRenderer) {
130 color =
d->displayRenderer->toQColor(c);
131 }
132 else {
134 }
135
136 for (
int x = 0;
x < contentsRect_.width();
x++)
137 image.setPixel(x, y, color.rgba());
138 }
139 }
140 d->pixmap = QPixmap::fromImage(image);
142 }
143 painter->drawPixmap( contentsRect_,
d->pixmap, QRect( 0, 0,
d->pixmap.width(),
d->pixmap.height()) );
144}
KoMixColorsOp * mixColorsOp
const KoColorSpace * colorSpace() const
return the current colorSpace
void toQColor(QColor *c) const
a convenience method for the above.