Commit 0434c69d authored by Cyrille Berger's avatar Cyrille Berger

API Sanitazation, QColor now includes an alpha channel, so use it directly...

API Sanitazation, QColor now includes an alpha channel, so use it directly instead of passing a pointer to an integer

svn path=/trunk/koffice/; revision=767751
parent 59b8fe22
......@@ -151,28 +151,14 @@ class KisRgbFloatHDRColorSpace : public KoIncompleteColorSpace<_CSTraits>
dst[ _CSTraits::red_pos ] = EXPOSURE_CORRECTED_UINT8_TO_FLOAT(c.red());
dst[ _CSTraits::green_pos ] = EXPOSURE_CORRECTED_UINT8_TO_FLOAT(c.green());
dst[ _CSTraits::blue_pos ] = EXPOSURE_CORRECTED_UINT8_TO_FLOAT(c.blue());
}
virtual void fromQColor(const QColor& c, quint8 opacity, quint8 *dstU8, const KoColorProfile * /*profile*/) const
{
typename _CSTraits::channels_type* dst = _CSTraits::nativeArray(dstU8);
dst[ _CSTraits::red_pos ] = EXPOSURE_CORRECTED_UINT8_TO_FLOAT(c.red());
dst[ _CSTraits::green_pos ] = EXPOSURE_CORRECTED_UINT8_TO_FLOAT(c.green());
dst[ _CSTraits::blue_pos ] = EXPOSURE_CORRECTED_UINT8_TO_FLOAT(c.blue());
dst[ _CSTraits::alpha_pos ] = UINT8_TO_FLOAT(opacity);
dst[ _CSTraits::alpha_pos ] = UINT8_TO_FLOAT(c.alpha());
}
virtual void toQColor(const quint8 *srcU8, QColor *c, const KoColorProfile * /*profile*/) const
{
const typename _CSTraits::channels_type* src = _CSTraits::nativeArray(srcU8);
c->setRgb(EXPOSURE_CORRECTED_FLOAT_TO_UINT8(src[_CSTraits::red_pos]), EXPOSURE_CORRECTED_FLOAT_TO_UINT8(src[_CSTraits::green_pos]), EXPOSURE_CORRECTED_FLOAT_TO_UINT8(src[_CSTraits::blue_pos]));
}
virtual void toQColor(const quint8 *srcU8, QColor *c, quint8 *opacity, const KoColorProfile * /*profile*/) const
{
const typename _CSTraits::channels_type* src = _CSTraits::nativeArray(srcU8);
c->setRgb(EXPOSURE_CORRECTED_FLOAT_TO_UINT8(src[_CSTraits::red_pos]), EXPOSURE_CORRECTED_FLOAT_TO_UINT8(src[_CSTraits::green_pos]), EXPOSURE_CORRECTED_FLOAT_TO_UINT8(src[_CSTraits::blue_pos]));
*opacity = FLOAT_TO_UINT8(src[_CSTraits::alpha_pos]);
c->setAlpha(FLOAT_TO_UINT8(src[_CSTraits::alpha_pos]));
}
quint8 difference(const quint8 *src1U8, const quint8 *src2U8)
......
......@@ -53,18 +53,7 @@ class KisYCbCrBaseColorSpace : public KoIncompleteColorSpace<_CSTraits>
dst->Y = _CSTraits::computeY( red, green, blue);
dst->Cb = _CSTraits::computeCb( red, green, blue);
dst->Cr = _CSTraits::computeCr( red, green, blue);
}
virtual void fromQColor(const QColor& c, quint8 opacity, quint8 *dstU8, const KoColorProfile * /*profile*/) const
{
typename _CSTraits::Pixel *dst = reinterpret_cast<typename _CSTraits::Pixel *>(dstU8);
typename _CSTraits::channels_type red = UINT8_TO_NATIVE(c.red());
typename _CSTraits::channels_type green = UINT8_TO_NATIVE(c.green());
typename _CSTraits::channels_type blue = UINT8_TO_NATIVE(c.blue());
dst->Y = _CSTraits::computeY( red, green, blue);
dst->Cb = _CSTraits::computeCb( red, green, blue);
dst->Cr = _CSTraits::computeCr( red, green, blue);
dst->alpha = UINT8_TO_NATIVE(opacity);
dst->alpha = UINT8_TO_NATIVE(c.alpha());
}
virtual void toQColor(const quint8 *srcU8, QColor *c, const KoColorProfile * /*profile*/) const
......@@ -74,17 +63,9 @@ class KisYCbCrBaseColorSpace : public KoIncompleteColorSpace<_CSTraits>
NATIVE_TO_UINT8(_CSTraits::computeRed( src->Y, src->Cb, src->Cr)),
NATIVE_TO_UINT8(_CSTraits::computeGreen( src->Y, src->Cb, src->Cr)),
NATIVE_TO_UINT8(_CSTraits::computeBlue( src->Y, src->Cb, src->Cr) ) );
c->setAlpha( NATIVE_TO_UINT8(src->alpha) );
}
virtual void toQColor(const quint8 *srcU8, QColor *c, quint8 *opacity, const KoColorProfile * /*profile*/) const
{
const typename _CSTraits::Pixel* src = reinterpret_cast<const typename _CSTraits::Pixel *>(srcU8);
c->setRgb(
NATIVE_TO_UINT8(_CSTraits::computeRed( src->Y, src->Cb, src->Cr)),
NATIVE_TO_UINT8(_CSTraits::computeGreen( src->Y, src->Cb, src->Cr)),
NATIVE_TO_UINT8(_CSTraits::computeBlue( src->Y, src->Cb, src->Cr) ) );
*opacity = NATIVE_TO_UINT8(src->alpha);
}
virtual void colorToXML( const quint8* pixel, QDomDocument& doc, QDomElement& colorElt) const
{
const typename _CSTraits::Pixel* p = reinterpret_cast<const typename _CSTraits::Pixel*>( pixel );
......
......@@ -254,14 +254,14 @@ QImage KisAdjustmentLayer::createThumbnail(qint32 w, qint32 h)
w = qint32(double(srcw) / srch * h);
QColor c;
quint8 opacity;
QImage img(w, h, QImage::Format_RGB32);
for (qint32 y=0; y < h; ++y) {
qint32 iY = (y * srch ) / h;
for (qint32 x=0; x < w; ++x) {
qint32 iX = (x * srcw ) / w;
m_d->selection->pixel(iX, iY, &c, &opacity);
m_d->selection->pixel(iX, iY, &c );
quint8 opacity = c.alpha();
img.setPixel(x, y, qRgb(opacity, opacity, opacity));
}
}
......
......@@ -299,9 +299,12 @@ KisSelectionSP KisFillPainter::createFloodSelection(int startX, int startY, KisP
KisHLineIteratorPixel selIt = pSel->createHLineIterator(0, y, m_width);
selIt += x;
if (m_fuzzy)
colorSpace->fromQColor(Qt::white, MAX_SELECTED - diff, selIt.rawData());
{
colorSpace->fromQColor(Qt::white, selIt.rawData());
colorSpace->setAlpha( selIt.rawData(), MAX_SELECTED - diff, 1 );
}
else
colorSpace->fromQColor(Qt::white, MAX_SELECTED, selIt.rawData());
colorSpace->fromQColor(Qt::white, selIt.rawData());
if (y > 0 && (map[m_width * (y - 1) + x] == None)) {
map[m_width * (y - 1) + x] = Added;
......@@ -331,9 +334,12 @@ KisSelectionSP KisFillPainter::createFloodSelection(int startX, int startY, KisP
}
if (m_fuzzy)
colorSpace->fromQColor(Qt::white, MAX_SELECTED - diff, selIt.rawData());
{
colorSpace->fromQColor(Qt::white, selIt.rawData());
colorSpace->setAlpha( selIt.rawData(), MAX_SELECTED - diff, 1);
}
else
colorSpace->fromQColor(Qt::white, MAX_SELECTED, selIt.rawData());
colorSpace->fromQColor(Qt::white, selIt.rawData());
if (y > 0 && (map[m_width * (y - 1) + x] == None)) {
map[m_width * (y - 1) + x] = Added;
......@@ -371,9 +377,12 @@ KisSelectionSP KisFillPainter::createFloodSelection(int startX, int startY, KisP
}
if (m_fuzzy)
colorSpace->fromQColor(Qt::white, MAX_SELECTED - diff, selIt.rawData());
{
colorSpace->fromQColor(Qt::white, selIt.rawData());
colorSpace->setAlpha( selIt.rawData(), MAX_SELECTED - diff, 1);
}
else
colorSpace->fromQColor(Qt::white, MAX_SELECTED, selIt.rawData());
colorSpace->fromQColor(Qt::white, selIt.rawData());
if (y > 0 && (map[m_width * (y - 1) + x] == None)) {
map[m_width * (y - 1) + x] = Added;
......
......@@ -116,7 +116,8 @@ KisPaintDevice::KisPaintDevice(KisNodeWSP parent, const KoColorSpace * colorSpac
m_d->nChannels = m_d->colorSpace->channelCount();
quint8 *defaultPixel = new quint8[ m_d->pixelSize ];
m_d->colorSpace->fromQColor(Qt::black, OPACITY_TRANSPARENT, defaultPixel);
m_d->colorSpace->fromQColor(Qt::black, defaultPixel);
m_d->colorSpace->setAlpha( defaultPixel, OPACITY_TRANSPARENT, 1 );
m_datamanager = new KisDataManager(m_d->pixelSize, defaultPixel);
delete [] defaultPixel;
......@@ -824,7 +825,7 @@ void KisPaintDevice::applySelectionMask(KisSelectionSP mask)
}
}
bool KisPaintDevice::pixel(qint32 x, qint32 y, QColor *c, quint8 *opacity)
bool KisPaintDevice::pixel(qint32 x, qint32 y, QColor *c)
{
KisHLineConstIteratorPixel iter = createHLineIterator(x, y, 1);
......@@ -832,7 +833,7 @@ bool KisPaintDevice::pixel(qint32 x, qint32 y, QColor *c, quint8 *opacity)
if (!pix) return false;
colorSpace()->toQColor(pix, c, opacity);
colorSpace()->toQColor(pix, c);
return true;
}
......@@ -851,11 +852,11 @@ bool KisPaintDevice::pixel(qint32 x, qint32 y, KoColor * kc)
return true;
}
bool KisPaintDevice::setPixel(qint32 x, qint32 y, const QColor& c, quint8 opacity)
bool KisPaintDevice::setPixel(qint32 x, qint32 y, const QColor& c)
{
KisHLineIteratorPixel iter = createHLineIterator(x, y, 1);
colorSpace()->fromQColor(c, opacity, iter.rawData());
colorSpace()->fromQColor(c, iter.rawData());
return true;
}
......
......@@ -329,7 +329,7 @@ public:
*
* @return true if the operation was successful.
*/
bool pixel(qint32 x, qint32 y, QColor *c, quint8 *opacity);
bool pixel(qint32 x, qint32 y, QColor *c);
/**
......@@ -358,7 +358,7 @@ public:
* @return true if the operation was successful
*
*/
bool setPixel(qint32 x, qint32 y, const QColor& c, quint8 opacity);
bool setPixel(qint32 x, qint32 y, const QColor& c);
bool setPixel(qint32 x, qint32 y, const KoColor& kc);
......
......@@ -136,19 +136,19 @@ void KisPaintDeviceTest::testGeometry()
quint8 opacity;
dev->clear( QRect( 50, 50, 50, 50 ) );
dev->pixel( 80, 80, &c, &opacity );
dev->pixel( 80, 80, &c );
QVERIFY( c == Qt::black );
QVERIFY( opacity == OPACITY_TRANSPARENT );
QVERIFY( c.alpha() == OPACITY_TRANSPARENT );
dev->fill( 0, 0, 512, 512, pixel);
dev->pixel( 80, 80, &c, &opacity );
dev->pixel( 80, 80, &c );
QVERIFY( c == Qt::white );
QVERIFY( opacity == OPACITY_OPAQUE );
QVERIFY( c.alpha() == OPACITY_OPAQUE );
dev->clear();
dev->pixel( 80, 80, &c, &opacity );
dev->pixel( 80, 80, &c );
QVERIFY( c == Qt::black );
QVERIFY( opacity == OPACITY_TRANSPARENT );
QVERIFY( c.alpha() == OPACITY_TRANSPARENT );
// XXX: No idea why we get this extent and bounds after a clear --
// but I want to know as soon as possible if this behaviour
......@@ -332,15 +332,16 @@ void KisPaintDeviceTest::testPixel()
QColor c = Qt::red;
quint8 opacity = 125;
dev->setPixel( 5, 5, c, opacity );
c.setAlpha( opacity );
dev->setPixel( 5, 5, c );
QColor c2;
quint8 opacity2;
dev->pixel( 5, 5, &c2, &opacity2 );
dev->pixel( 5, 5, &c2 );
QVERIFY( c == c2 );
QVERIFY( opacity2 == opacity2 );
QVERIFY( opacity == c2.alpha() );
}
......@@ -394,20 +395,18 @@ void KisPaintDeviceTest::testMirror()
dev->fill( 512, 0, 512, 512, pixel );
QColor c1;
quint8 opacity1;
dev->pixel( 5, 5, &c1, &opacity1 );
dev->pixel( 5, 5, &c1 );
QColor c2;
quint8 opacity2;
dev->pixel( 517, 5, &c2, &opacity2 );
dev->pixel( 517, 5, &c2 );
QVERIFY( c1 == Qt::white );
QVERIFY( c2 == Qt::black );
dev->mirrorX();
dev->pixel( 5, 5, &c1, &opacity1 );
dev->pixel( 517, 5, &c2, &opacity2 );
dev->pixel( 5, 5, &c1 );
dev->pixel( 517, 5, &c2 );
QVERIFY( c1 == Qt::black );
QVERIFY( c2 == Qt::white );
......@@ -418,8 +417,8 @@ void KisPaintDeviceTest::testMirror()
cs->fromQColor( Qt::black, pixel );
dev->fill( 0, 512, 512, 512, pixel );
dev->pixel( 5, 5, &c1, &opacity1 );
dev->pixel( 5, 517, &c2, &opacity2 );
dev->pixel( 5, 5, &c1 );
dev->pixel( 5, 517, &c2 );
QVERIFY( c1 == Qt::white );
QVERIFY( c2 == Qt::black );
......@@ -427,8 +426,8 @@ void KisPaintDeviceTest::testMirror()
dev->mirrorY();
dev->convertToQImage(0, 0, 0, 1024, 512).save( "mirror.png" );
dev->pixel( 5, 5, &c1, &opacity1 );
dev->pixel( 5, 517, &c2, &opacity2 );
dev->pixel( 5, 5, &c1 );
dev->pixel( 5, 517, &c2 );
QVERIFY( c1 == Qt::black );
QVERIFY( c2 == Qt::white );
......@@ -457,12 +456,10 @@ void KisPaintDeviceTest::testMirrorTransaction()
dev->fill( 512, 0, 512, 512, pixel );
QColor c1;
quint8 opacity1;
dev->pixel( 5, 5, &c1, &opacity1 );
dev->pixel( 5, 5, &c1 );
QColor c2;
quint8 opacity2;
dev->pixel( 517, 5, &c2, &opacity2 );
dev->pixel( 517, 5, &c2 );
QVERIFY( c1 == Qt::white );
QVERIFY( c2 == Qt::black );
......@@ -471,8 +468,8 @@ void KisPaintDeviceTest::testMirrorTransaction()
KisTransaction t( "mirror", dev, 0 );
dev->mirrorX();
dev->pixel( 5, 5, &c1, &opacity1 );
dev->pixel( 517, 5, &c2, &opacity2 );
dev->pixel( 5, 5, &c1 );
dev->pixel( 517, 5, &c2 );
dev->convertToQImage( 0, 0, 0, 1024, 512 ).save( "mirror.png" );
QVERIFY( c1 == Qt::black );
......@@ -484,16 +481,16 @@ void KisPaintDeviceTest::testMirrorTransaction()
cs->fromQColor( Qt::black, pixel );
dev->fill( 0, 512, 512, 512, pixel );
dev->pixel( 5, 5, &c1, &opacity1 );
dev->pixel( 5, 517, &c2, &opacity2 );
dev->pixel( 5, 5, &c1 );
dev->pixel( 5, 517, &c2 );
QVERIFY( c1 == Qt::white );
QVERIFY( c2 == Qt::black );
dev->mirrorY();
dev->pixel( 5, 5, &c1, &opacity1 );
dev->pixel( 5, 517, &c2, &opacity2 );
dev->pixel( 5, 5, &c1 );
dev->pixel( 5, 517, &c2 );
QVERIFY( c1 == Qt::black );
QVERIFY( c2 == Qt::white );
......@@ -514,12 +511,11 @@ void KisPaintDeviceTest::testPlanarReadWrite()
KisPaintDeviceSP dev = new KisPaintDevice( cs );
quint8* pixel = cs->allocPixelBuffer( 1 );
cs->fromQColor( QColor( 255, 200, 155), 100, pixel );
cs->fromQColor( QColor( 255, 200, 155, 100), pixel );
dev->fill( 0, 0, 5000, 5000, pixel);
QColor c1;
quint8 opacity1;
dev->pixel( 5, 5, &c1, &opacity1 );
dev->pixel( 5, 5, &c1 );
QVector<quint8*> planes = dev->readPlanarBytes( 500, 500, 100, 100 );
QVector<quint8*> swappedPlanes;
......@@ -542,19 +538,19 @@ void KisPaintDeviceTest::testPlanarReadWrite()
dev->convertToQImage(0, 0, 0, 5000, 5000).save( "planar.png" );
dev->pixel( 5, 5, &c1, &opacity1 );
dev->pixel( 5, 5, &c1 );
QVERIFY( c1.red() == 200 );
QVERIFY( c1.green() == 255 );
QVERIFY( c1.blue() == 100);
QVERIFY( opacity1 == 155 );
QVERIFY( c1.alpha() == 155 );
dev->pixel( 75, 50, &c1, &opacity1 );
dev->pixel( 75, 50, &c1 );
QVERIFY( c1.red() == 200 );
QVERIFY( c1.green() == 255 );
QVERIFY( c1.blue() == 100);
QVERIFY( opacity1 == 155 );
QVERIFY( c1.alpha() == 155 );
}
QTEST_KDEMAIN(KisPaintDeviceTest, GUI)
......
......@@ -90,7 +90,9 @@ void KisPainterTest::testPaintDeviceBltSelection(const KoColorSpace * cs)
KisPaintDeviceSP dst = new KisPaintDevice( cs, "dst");
KisPaintDeviceSP src = new KisPaintDevice( cs, "src" );
src->fill( 0, 0, 20, 20, KoColor( Qt::red, 128, cs ).data() );
KoColor c( Qt::red, cs );
c.setOpacity( 128 );
src->fill( 0, 0, 20, 20, c.data() );
QCOMPARE( src->exactBounds(), QRect( 0, 0, 20, 20 ) );
......@@ -156,11 +158,10 @@ void KisPainterTest::testPaintDeviceBltSelectionIrregular(const KoColorSpace * c
// this colorspace
if ( channel->channelType() == KoChannelInfo::ALPHA ) {
QColor c;
quint8 alpha;
dst->pixel( 13, 13, &c, &alpha );
dst->pixel( 13, 13, &c );
QCOMPARE( ( int ) alpha, ( int ) OPACITY_TRANSPARENT );
QCOMPARE( ( int ) c.alpha(), ( int ) OPACITY_TRANSPARENT );
}
}
}
......
......@@ -41,12 +41,10 @@ void KisTransactionTest::testUndo()
dev->fill( 512, 0, 512, 512, pixel );
QColor c1;
quint8 opacity1;
dev->pixel( 5, 5, &c1, &opacity1 );
dev->pixel( 5, 5, &c1 );
QColor c2;
quint8 opacity2;
dev->pixel( 517, 5, &c2, &opacity2 );
dev->pixel( 517, 5, &c2 );
QVERIFY( c1 == Qt::white );
QVERIFY( c2 == Qt::black );
......@@ -56,8 +54,8 @@ void KisTransactionTest::testUndo()
t.undo();
dev->pixel( 5, 5, &c1, &opacity1 );
dev->pixel( 517, 5, &c2, &opacity2 );
dev->pixel( 5, 5, &c1 );
dev->pixel( 517, 5, &c2 );
QVERIFY( c1 == Qt::white );
QVERIFY( c2 == Qt::black );
......@@ -77,12 +75,10 @@ void KisTransactionTest::testRedo()
dev->fill( 512, 0, 512, 512, pixel );
QColor c1;
quint8 opacity1;
dev->pixel( 5, 5, &c1, &opacity1 );
dev->pixel( 5, 5, &c1 );
QColor c2;
quint8 opacity2;
dev->pixel( 517, 5, &c2, &opacity2 );
dev->pixel( 517, 5, &c2 );
QVERIFY( c1 == Qt::white );
QVERIFY( c2 == Qt::black );
......@@ -93,8 +89,8 @@ void KisTransactionTest::testRedo()
t.undo();
t.redo();
dev->pixel( 5, 5, &c1, &opacity1 );
dev->pixel( 517, 5, &c2, &opacity2 );
dev->pixel( 5, 5, &c1 );
dev->pixel( 517, 5, &c2 );
QVERIFY( c1 == Qt::black );
QVERIFY( c2 == Qt::white );
......
......@@ -112,7 +112,6 @@ void KisEmbossFilter::process(KisFilterConstProcessingInformation srcInfo,
KisHLineIteratorPixel dstIt = dst->createHLineIterator(dstTopLeft.x(), dstTopLeft.y(), size.width(), dstInfo.selection());
QColor color1;
QColor color2;
quint8 opacity;
for (int y = 0 ; not(progressUpdater and progressUpdater->interrupted()) and (y < Height) ; ++y)
{
KisRandomConstAccessorPixel acc = src->createRandomConstAccessor(srcTopLeft.x(), srcTopLeft.y());
......@@ -124,7 +123,7 @@ void KisEmbossFilter::process(KisFilterConstProcessingInformation srcInfo,
// FIXME: COLORSPACE_INDEPENDENCE or at least work IN RGB16A
src->colorSpace()->toQColor( it.oldRawData(), &color1, &opacity);
src->colorSpace()->toQColor( it.oldRawData(), &color1 );
acc.moveTo(srcTopLeft.x() + x + Lim_Max(x, 1, Width), srcTopLeft.y() + y + Lim_Max(y, 1, Height) );
src->colorSpace()->toQColor(acc.oldRawData(), &color2);
......@@ -135,7 +134,7 @@ void KisEmbossFilter::process(KisFilterConstProcessingInformation srcInfo,
Gray = CLAMP((R + G + B) / 3, 0, quint8_MAX);
dst->colorSpace()->fromQColor(QColor(Gray, Gray, Gray), opacity, dstIt.rawData());
dst->colorSpace()->fromQColor(QColor(Gray, Gray, Gray, color1.alpha()), dstIt.rawData());
}
}
it.nextRow();
......
......@@ -129,8 +129,11 @@ void Stroke::drawWuLine(KisPaintDeviceSP dev, double x1, double y1, double x2, d
double ypxl1 = static_cast<int>(yend); // Remove the fractional part the fast way
dev->setPixel( (qint32)xpxl1, (qint32)ypxl1, Qt::black, (qint32) ( (1 - modf(yend, &tmp)) * xgap) );
dev->setPixel( (qint32)xpxl1, (qint32)ypxl1 + 1, Qt::black, (qint32) ( modf(yend, &tmp) * xgap) );
QColor black = Qt::black;
black.setAlpha((qint32) ( (1 - modf(yend, &tmp)) * xgap));
dev->setPixel( (qint32)xpxl1, (qint32)ypxl1, black );
black.setAlpha((qint32) ( modf(yend, &tmp) * xgap));
dev->setPixel( (qint32)xpxl1, (qint32)ypxl1 + 1, black );
double intery = yend + gradient; // first y-intersection for the main loop
......@@ -142,13 +145,17 @@ void Stroke::drawWuLine(KisPaintDeviceSP dev, double x1, double y1, double x2, d
double xpxl2 = xend; // this will be used in the main loop
double ypxl2 = static_cast<int>(yend);
dev->setPixel( (qint32)xpxl2, (qint32)ypxl2, Qt::black, (qint32) ( (1 - modf(yend, &tmp)) * xgap) );
dev->setPixel( (qint32)xpxl2, (qint32)ypxl2 + 1, Qt::black, (qint32) ( modf(yend, &tmp) * xgap) );
black.setAlpha( (qint32) ( (1 - modf(yend, &tmp)) * xgap) );
dev->setPixel( (qint32)xpxl2, (qint32)ypxl2, black );
black.setAlpha( (qint32) ( modf(yend, &tmp) * xgap) );
dev->setPixel( (qint32)xpxl2, (qint32)ypxl2 + 1, black);
// main loop
for (int x = (qint32)(xpxl1 + 1); x < xpxl2; ++x) {
dev->setPixel(x, static_cast<int>(intery), Qt::black, (qint32)(1 - modf(intery, &tmp)));
dev->setPixel(x, static_cast<int>(intery) + 1, Qt::black, (qint32)modf(intery, &tmp));
black.setAlpha( (qint32)(1 - modf(intery, &tmp)) );
dev->setPixel(x, static_cast<int>(intery), black );
black.setAlpha( (qint32)modf(intery, &tmp) );
dev->setPixel(x, static_cast<int>(intery) + 1, black );
intery = intery + gradient;
}
......
......@@ -132,6 +132,7 @@ void KisBristleShape::paintAt(const QPointF &brushPos, const KisPaintInformation
pos += brushPos;
// dbgPlugins << m_radius <<"" << pos <<"" << brushPos;
coloringsrc->colorAt( (int)pos.x(), (int)pos.y(), &color );
Q_ASSERT(m_paintBrush->bristlesPainter);
m_paintBrush->bristlesPainter->setPaintColor( color );
if( m_paintBrush->m_firstStroke)
{
......
......@@ -292,7 +292,6 @@ void DlgColorRange::slotSelectClicked()
qint32 x, y, w, h;
m_dev->exactBounds(x, y, w, h);
const KoColorSpace * cs = m_dev->colorSpace();
quint8 opacity;
KisHLineConstIterator hiter = m_dev->createHLineConstIterator(x, y, w);
KisHLineIterator selIter = m_selection ->createHLineIterator(x, y, w);
......@@ -301,9 +300,9 @@ void DlgColorRange::slotSelectClicked()
while (!hiter.isDone()) {
QColor c;
cs->toQColor(hiter.rawData(), &c, &opacity);
cs->toQColor(hiter.rawData(), &c);
// Don't try to select transparent pixels.
if (opacity > OPACITY_TRANSPARENT) {
if (c.alpha() > OPACITY_TRANSPARENT) {
quint8 match = matchColors(c, m_currentAction);
if (match) {
......
......@@ -98,7 +98,8 @@ void KisDropshadow::dropshadow(KoUpdater * progressUpdater, qint32 xoffset, qint
{
//set the shadow color
quint8 alpha = dev->colorSpace()->alpha(srcIt.rawData());
rgb8cs->fromQColor(color, alpha, dstIt.rawData());
color.setAlpha( alpha );
rgb8cs->fromQColor(color, dstIt.rawData());
}
++srcIt;
++dstIt;
......
......@@ -66,21 +66,19 @@ void KisAutogradient::slotSelectedSegment(KoGradientSegment* segment)
{
QColor startColor;
QColor endColor;
quint8 startOpacity;
quint8 endOpacity;
segment->startColor().toQColor( &startColor, &startOpacity);
segment->endColor().toQColor( &endColor, &endOpacity);
segment->startColor().toQColor( &startColor);
segment->endColor().toQColor( &endColor);
leftColorButton->setColor( startColor );
rightColorButton->setColor( endColor );
comboBoxColorInterpolationType->setCurrentIndex( segment->colorInterpolation() );
comboBoxInterpolationType->setCurrentIndex( segment->interpolation() );
int leftOpacity = qRound( startOpacity / OPACITY_OPAQUE * 100);
int leftOpacity = qRound( startColor.alpha() / OPACITY_OPAQUE * 100);
intNumInputLeftOpacity->setValue( leftOpacity );
int rightOpacity = qRound( endOpacity / OPACITY_OPAQUE * 100);
int rightOpacity = qRound( endColor.alpha() / OPACITY_OPAQUE * 100);
intNumInputRightOpacity->setValue( rightOpacity );
paramChanged();
......@@ -116,10 +114,9 @@ void KisAutogradient::slotChangedLeftColor( const QColor& color)
KoGradientSegment* segment = gradientSlider->selectedSegment();
if(segment)
{
QColor unused;
quint8 opacity;
segment->startColor().toQColor( &unused, &opacity);
segment->setStartColor( KoColor( color, opacity, segment->startColor().colorSpace() ) );
KoColor c( color, segment->startColor().colorSpace() );
c.setOpacity( segment->startColor().opacity() );
segment->setStartColor( c );
}
gradientSlider->update();
......@@ -132,9 +129,9 @@ void KisAutogradient::slotChangedRightColor( const QColor& color)
if(segment)
{
QColor unused;
quint8 opacity;
segment->endColor().toQColor( &unused, &opacity);
segment->setEndColor( KoColor( color, opacity, segment->endColor().colorSpace() ) );
KoColor c( color, segment->endColor().colorSpace() );