Commit e7be0b61 authored by Boudewijn Rempt's avatar Boudewijn Rempt

* Remove two deprecated methods from KoColorSpace and fix the rest of KOffice to follow that

* Make it possible to convolve a subset of channels, not just distinguish between color and
  alpha channels
* Set a few more baby steps towards being able to composite a subset of channels.

svn path=/trunk/koffice/; revision=646165
parent a2d43a36
......@@ -19,6 +19,7 @@
#define KIS_COLORSPACE_WET_STICKY_H_
#include <QColor>
#include <QBitArray>
#include "kis_global.h"
#include "kis_abstract_colorspace.h"
......@@ -111,7 +112,7 @@ public:
virtual void mixColors(const quint8 **colors, const quint8 *weights, quint32 nColors, quint8 *dst) const;
virtual void convolveColors(quint8** colors, qint32* kernelValues, KoChannelInfo::enumChannelFlags channelFlags, quint8 *dst, qint32 factor, qint32 offset, qint32 nColors) const;
virtual void convolveColors(quint8** colors, qint32* kernelValues, quint8 *dst, qint32 factor, qint32 offset, qint32 nColors, const QBitArray & channelFlags ) const;
virtual void invertColor(quint8 * src, qint32 nPixels);
virtual void darken(const quint8 * src, quint8 * dst, qint32 shade, bool compensate, double compensation, qint32 nPixels) const;
......
......@@ -86,8 +86,7 @@ KisConvolutionPainter::KisConvolutionPainter(KisPaintDeviceSP device) : super(de
}
void KisConvolutionPainter::applyMatrix(KisKernelSP kernel, qint32 x, qint32 y, qint32 w, qint32 h,
KisConvolutionBorderOp borderOp,
KoChannelInfo::enumChannelFlags channelFlags )
KisConvolutionBorderOp borderOp )
{
// Make the area we cover as small as possible
if (m_device->hasSelection()) {
......@@ -119,13 +118,14 @@ void KisConvolutionPainter::applyMatrix(KisKernelSP kernel, qint32 x, qint32 y,
emit notifyProgress(0);
KoColorSpace * cs = m_device->colorSpace();
KoConvolutionOp * convolutionOp = cs->convolutionOp();
// Determine whether we convolve border pixels, or not.
switch (borderOp) {
case BORDER_DEFAULT_FILL :
break;
case BORDER_REPEAT:
applyMatrixRepeat(kernel, x, y, w, h, channelFlags);
applyMatrixRepeat(kernel, x, y, w, h);
return;
case BORDER_WRAP:
case BORDER_AVOID:
......@@ -197,7 +197,7 @@ void KisConvolutionPainter::applyMatrix(KisKernelSP kernel, qint32 x, qint32 y,
}
}
if (hit.isSelected()) {
cs->convolveColors(pixelPtrCache, kernel->data, channelFlags, hit.rawData(), kernel->factor, kernel->offset, kw * kh);
convolutionOp->convolveColors(pixelPtrCache, kernel->data, hit.rawData(), kernel->factor, kernel->offset, kw * kh, m_channelFlags);
// pixelPtrCache.fill(0);
}
++col;
......@@ -232,8 +232,7 @@ void KisConvolutionPainter::applyMatrix(KisKernelSP kernel, qint32 x, qint32 y,
delete[] pixelPtrCache;
}
void KisConvolutionPainter::applyMatrixRepeat(KisKernelSP kernel, qint32 x, qint32 y, qint32 w, qint32 h,
KoChannelInfo::enumChannelFlags channelFlags)
void KisConvolutionPainter::applyMatrixRepeat( KisKernelSP kernel, qint32 x, qint32 y, qint32 w, qint32 h )
{
int lastProgressPercent = 0;
// Determine the kernel's extent from the center pixel
......@@ -247,6 +246,7 @@ void KisConvolutionPainter::applyMatrixRepeat(KisKernelSP kernel, qint32 x, qint
yLastMinuskhh = y + (h - khalfHeight);
KoColorSpace * cs = m_device->colorSpace();
KoConvolutionOp * convolutionOp = cs->convolutionOp();
// Iterate over all pixels in our rect, create a cache of pixels around the current pixel and convolve them in the colorspace.
......@@ -395,7 +395,7 @@ void KisConvolutionPainter::applyMatrixRepeat(KisKernelSP kernel, qint32 x, qint
}
}
if (hit.isSelected()) {
cs->convolveColors(pixelPtrCache, kernel->data, channelFlags, hit.rawData(), kernel->factor, kernel->offset, kw * kh);
convolutionOp->convolveColors(pixelPtrCache, kernel->data, hit.rawData(), kernel->factor, kernel->offset, kw * kh, m_channelFlags);
}
++col;
++hit;
......
......@@ -78,17 +78,19 @@ public:
* The channels flag determines which set out of color channels, alpha channels, substance or substrate
* channels we convolve.
*
* Note that we do not (currently) support different kernels for different channels _or_ channel types.
* Note that we do not (currently) support different kernels for
* different channels _or_ channel types.
*
* If you want to convolve a subset of the channels in a pixel,
* set those channels with KisPainter::setChannelFlags();
*/
void applyMatrix(KisKernelSP kernel, qint32 x, qint32 y, qint32 w, qint32 h,
KisConvolutionBorderOp borderOp = BORDER_AVOID,
KoChannelInfo::enumChannelFlags channelFlags = KoChannelInfo::FLAG_COLOR);
KisConvolutionBorderOp borderOp = BORDER_AVOID);
private:
/**
* This function is called by applyMatrix when borderOp == BORDER_REPEAT
*/
void applyMatrixRepeat(KisKernelSP kernel, qint32 x, qint32 y, qint32 w, qint32 h,
KoChannelInfo::enumChannelFlags channelFlags);
void applyMatrixRepeat(KisKernelSP kernel, qint32 x, qint32 y, qint32 w, qint32 h);
};
......
......@@ -450,7 +450,7 @@ void KisGradientSegment::RGBColorInterpolationStrategy::colorAt(KoColor& dst, do
colorWeights[0] = static_cast<quint8>((1.0 - t) * 255 + 0.5);
colorWeights[1] = 255 - colorWeights[0];
m_colorSpace->mixColors(colors, colorWeights, 2, buffer.data());
m_colorSpace->mixColorsOp()->mixColors(colors, colorWeights, 2, buffer.data());
dst.fromKoColor(buffer);
}
......
......@@ -83,6 +83,7 @@ public:
dy = sy;
KisPainter gc(m_projection);
gc.setChannelFlags( layer->channelFlags() );
gc.bitBlt(dx, dy, layer->compositeOp() , dev, layer->opacity(), sx, sy, w, h);
#ifdef DIRTY_AND_PROJECTION
layer->setClean( rc );
......@@ -121,6 +122,7 @@ public:
dy = sy;
KisPainter gc(m_projection);
gc.setChannelFlags( layer->channelFlags() );
KisPaintDeviceSP source = layer->projection();
if (!layer->hasMask()) {
......@@ -231,6 +233,7 @@ public:
dy = sy;
KisPainter gc(m_projection);
gc.setChannelFlags( layer->channelFlags() );
gc.bitBlt(dx, dy, layer->compositeOp(), dev, layer->opacity(), sx, sy, w, h);
#ifdef DIRTY_AND_PROJECTION
layer->setClean( rc );
......
......@@ -54,7 +54,7 @@ void KisRandomSubAccessorPixel::sampledOldRawData(Q_UINT8* dst)
weights[3] = (int)round( hsub * vsub * 255 );
m_randomAccessor.moveTo(x+1, y+1);
pixels[3] = m_randomAccessor.oldRawData();
m_device->colorSpace()->mixColors(pixels, weights, 4, dst);
m_device->colorSpace()->mixColorsOp()->mixColors(pixels, weights, 4, dst);
}
void KisRandomSubAccessorPixel::sampledRawData(Q_UINT8* dst)
......@@ -79,6 +79,6 @@ void KisRandomSubAccessorPixel::sampledRawData(Q_UINT8* dst)
weights[3] = (int)round( hsub * vsub * 255 );
m_randomAccessor.moveTo(x+1, y+1);
pixels[3] = m_randomAccessor.rawData();
m_device->colorSpace()->mixColors(pixels, weights, 4, dst);
m_device->colorSpace()->mixColorsOp()->mixColors(pixels, weights, 4, dst);
}
......@@ -287,9 +287,11 @@ KisPaintDeviceSP KisRotateVisitor::xShear(KisPaintDeviceSP src, double shearX)
QRect r = src->exactBounds();
double displacement;
qint32 displacementInt;
double weight;
double displacement;
qint32 displacementInt;
double weight;
KoMixColorsOp * mixOp = src->colorSpace()->mixColorsOp();
for (qint32 y = r.top(); y <= r.bottom(); y++) {
......@@ -315,7 +317,7 @@ KisPaintDeviceSP KisRotateVisitor::xShear(KisPaintDeviceSP src, double shearX)
pixelPtrs[0] = leftSrcIt.rawData();
pixelPtrs[1] = srcIt.rawData();
src->colorSpace()->mixColors(pixelPtrs, pixelWeights, 2, dstIt.rawData());
mixOp->mixColors(pixelPtrs, pixelWeights, 2, dstIt.rawData());
++srcIt;
++leftSrcIt;
......@@ -330,14 +332,16 @@ KisPaintDeviceSP KisRotateVisitor::xShear(KisPaintDeviceSP src, double shearX)
KisPaintDeviceSP KisRotateVisitor::yShear(KisPaintDeviceSP src, double shearY)
{
KisPaintDeviceSP dst = KisPaintDeviceSP(new KisPaintDevice(src->colorSpace(), "yShear"));
KoMixColorsOp * mixOp = src->colorSpace()->mixColorsOp();
dst->setX(src->getX());
dst->setY(src->getY());
QRect r = src->exactBounds();
double displacement;
qint32 displacementInt;
double weight;
double displacement;
qint32 displacementInt;
double weight;
for (qint32 x = r.left(); x <= r.right(); x++) {
......@@ -363,7 +367,7 @@ KisPaintDeviceSP KisRotateVisitor::yShear(KisPaintDeviceSP src, double shearY)
pixelPtrs[0] = leftSrcIt.rawData();
pixelPtrs[1] = srcIt.rawData();
src->colorSpace()->mixColors(pixelPtrs, pixelWeights, 2, dstIt.rawData());
mixOp->mixColors(pixelPtrs, pixelWeights, 2, dstIt.rawData());
++srcIt;
++leftSrcIt;
......
......@@ -315,6 +315,7 @@ template <class T> void KisTransformWorker::transformPass(KisPaintDevice *src, K
quint8 pixelSize = src->pixelSize();
KisSelectionSP dstSelection;
KoColorSpace * cs = src->colorSpace();
KoMixColorsOp * mixOp = cs->mixColorsOp();
qint32 scale;
qint32 scaleDenom;
qint32 shearFracOffset;
......@@ -499,7 +500,7 @@ template <class T> void KisTransformWorker::transformPass(KisPaintDevice *src, K
num++;
}
data = dstIt.rawData();
cs->mixColors(colors, filterWeights[center&255].weight, filterWeights[center&255].numWeights, data);
mixOp->mixColors(colors, filterWeights[center&255].weight, filterWeights[center&255].numWeights, data);
data = dstSelIt.rawData();
*data = selectedness;
}
......
......@@ -12,6 +12,7 @@ add_subdirectory( imageenhancement )
# add_subdirectory( raindropsfilter )
# add_subdirectory( roundcorners )
# add_subdirectory( smalltilesfilter )
# add_subdirectory( cubismfilter )
add_subdirectory( sobelfilter )
add_subdirectory( colorsfilters )
add_subdirectory( wavefilter )
......
......@@ -171,6 +171,8 @@ void KisAutoContrast::process(const KisPaintDeviceSP src, const QPoint& srcTopLe
setProgressTotalSteps(size.width() * size.height());
qint32 pixelsProcessed = 0;
KoMixColorsOp * mixOp = src->colorSpace()->mixColorsOp();
while( ! iter.isDone() && !cancelRequested())
{
quint32 npix=0, maxpix = iter.nConseqPixels();
......@@ -210,7 +212,7 @@ void KisAutoContrast::process(const KisPaintDeviceSP src, const QPoint& srcTopLe
adj->transform(iter.oldRawData(), iter.rawData(), 1);
const quint8 *pixels[2] = {iter.oldRawData(), iter.rawData()};
quint8 weights[2] = {MAX_SELECTED - selectedness, selectedness};
src->colorSpace()->mixColors(pixels, weights, 2, iter.rawData());
mixOp->mixColors(pixels, weights, 2, iter.rawData());
++iter;
pixelsProcessed++;
break;
......@@ -248,6 +250,8 @@ bool KisDesaturateFilter::workWith(KoColorSpace* cs)
void KisDesaturateFilter::process(const KisPaintDeviceSP src, const QPoint& srcTopLeft, KisPaintDeviceSP dst, const QPoint& dstTopLeft, const QSize& size, KisFilterConfiguration* config)
{
Q_UNUSED( config );
if (dst != src) {
KisPainter gc(dst);
gc.bitBlt(dstTopLeft.x(), dstTopLeft.y(), COMPOSITE_COPY, src, srcTopLeft.x(), srcTopLeft.y(), size.width(), size.height());
......@@ -263,6 +267,7 @@ void KisDesaturateFilter::process(const KisPaintDeviceSP src, const QPoint& srcT
setProgressTotalSteps(size.width() * size.height());
qint32 pixelsProcessed = 0;
KoMixColorsOp * mixOp = src->colorSpace()->mixColorsOp();
while( ! iter.isDone() && !cancelRequested())
{
......@@ -304,7 +309,7 @@ void KisDesaturateFilter::process(const KisPaintDeviceSP src, const QPoint& srcT
m_adj->transform(iter.oldRawData(), iter.rawData(), 1);
const quint8 *pixels[2] = {iter.oldRawData(), iter.rawData()};
quint8 weights[2] = {MAX_SELECTED - selectedness, selectedness};
src->colorSpace()->mixColors(pixels, weights, 2, iter.rawData());
mixOp->mixColors(pixels, weights, 2, iter.rawData());
++iter;
pixelsProcessed++;
break;
......
......@@ -199,7 +199,7 @@ void KisBrightnessContrastFilter::process(const KisPaintDeviceSP src, const QPoi
setProgressTotalSteps(size.width() * size.height());
qint32 pixelsProcessed = 0;
KoMixColorsOp * mixOp = src->colorSpace()->mixColorsOp();
while( ! iter.isDone() && !cancelRequested())
{
quint32 npix=0, maxpix = iter.nConseqPixels();
......@@ -240,7 +240,7 @@ void KisBrightnessContrastFilter::process(const KisPaintDeviceSP src, const QPoi
configBC->m_adjustment->transform(iter.oldRawData(), iter.rawData(), 1);
const quint8 *pixels[2] = {iter.oldRawData(), iter.rawData()};
quint8 weights[2] = {MAX_SELECTED - selectedness, selectedness};
src->colorSpace()->mixColors(pixels, weights, 2, iter.rawData());
mixOp->mixColors(pixels, weights, 2, iter.rawData());
++iter;
pixelsProcessed++;
break;
......
......@@ -209,7 +209,7 @@ void KisPerChannelFilter::process(const KisPaintDeviceSP src, const QPoint& srcT
}
KisRectIteratorPixel iter = dst->createRectIterator(dstTopLeft.x(), dstTopLeft.y(), size.width(), size.height() );
KoMixColorsOp * mixOp = src->colorSpace()->mixColorsOp();
setProgressTotalSteps(size.width() * size.height());
qint32 pixelsProcessed = 0;
......@@ -254,7 +254,7 @@ void KisPerChannelFilter::process(const KisPaintDeviceSP src, const QPoint& srcT
adj->transform(iter.oldRawData(), iter.rawData(), 1);
const quint8 *pixels[2] = {iter.oldRawData(), iter.rawData()};
quint8 weights[2] = {MAX_SELECTED - selectedness, selectedness};
src->colorSpace()->mixColors(pixels, weights, 2, iter.rawData());
mixOp->mixColors(pixels, weights, 2, iter.rawData());
++iter;
pixelsProcessed++;
break;
......
......@@ -85,25 +85,28 @@ void KisFilterNoise::process(const KisPaintDeviceSP src, const QPoint& srcTopLef
{
Q_ASSERT(src != 0);
Q_ASSERT(dst != 0);
setProgressTotalSteps(size.width() * size.height());
KoColorSpace * cs = src->colorSpace();
QVariant value;
int level = (config && config->getProperty("level", value)) ? value.toInt() : 50;
int opacity = (config && config->getProperty("opacity", value)) ? value.toInt() : 100;
KisRectIteratorPixel dstIt = dst->createRectIterator(dstTopLeft.x(), dstTopLeft.y(), size.width(), size.height() );
KisRectConstIteratorPixel srcIt = src->createRectConstIterator(srcTopLeft.x(), srcTopLeft.y(), size.width(), size.height());
Q_UINT8* interm = new Q_UINT8[ cs->pixelSize() ];
Q_INT32 threshold = (RAND_MAX / 100) * (100 - level);
Q_UINT8 weights[2];
weights[0] = (255 * opacity) / 100; weights[1] = 255 - weights[0];
const Q_UINT8* pixels[2];
pixels[0] = interm;
KoMixColorsOp * mixOp = cs->mixColorsOp();
while(!srcIt.isDone())
{
if(rand() > threshold)
......@@ -114,13 +117,13 @@ void KisFilterNoise::process(const KisPaintDeviceSP src, const QPoint& srcTopLef
static_cast<int>((double)rand()/RAND_MAX * 255));
cs->fromQColor( c, interm, 0 );
pixels[1] = srcIt.oldRawData();
cs->mixColors( pixels, weights, 2, dstIt.rawData() );
mixOp->mixColors( pixels, weights, 2, dstIt.rawData() );
}
++srcIt;
++dstIt;
incProgress();
}
delete [] interm;
setProgressDone(); // Must be called even if you don't really support progression
}
......
......@@ -87,24 +87,25 @@ void KisFilterRandomPick::process(const KisPaintDeviceSP src, const QPoint& srcT
{
Q_ASSERT(src != 0);
Q_ASSERT(dst != 0);
setProgressTotalSteps(size.height() * size.width());
KoColorSpace * cs = src->colorSpace();
QVariant value;
int level = (config && config->getProperty("level", value)) ? value.toInt() : 50;
int opacity = (config && config->getProperty("opacity", value)) ? value.toInt() : 100;
KisRectIteratorPixel dstIt = dst->createRectIterator(dstTopLeft.x(), dstTopLeft.y(), size.width(), size.height());
KisRectConstIteratorPixel srcIt = src->createRectConstIterator(srcTopLeft.x(), srcTopLeft.y(), size.width(), size.height());
KisRandomConstAccessorPixel srcRA = src->createRandomConstAccessor(0, 0);
Q_INT32 threshold = (RAND_MAX / 100) * (100 - level);
Q_UINT8 weights[2];
weights[0] = (255 * opacity) / 100; weights[1] = 255 - weights[0];
const Q_UINT8* pixels[2];
KoMixColorsOp * mixOp = cs->mixColorsOp();
while(!srcIt.isDone())
{
if(rand() > threshold)
......@@ -114,12 +115,12 @@ void KisFilterRandomPick::process(const KisPaintDeviceSP src, const QPoint& srcT
srcRA.moveTo( x, y);
pixels[0] = srcRA.oldRawData();
pixels[1] = srcIt.oldRawData();
cs->mixColors( pixels, weights, 2, dstIt.rawData() );
mixOp->mixColors( pixels, weights, 2, dstIt.rawData() );
}
++srcIt;
++dstIt;
incProgress();
}
setProgressDone(); // Must be called even if you don't really support progression
}
......@@ -17,7 +17,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include <QBitArray>
#include "kis_unsharp_filter.h"
#include <kcombobox.h>
......@@ -75,9 +75,13 @@ void KisUnsharpFilter::process(const KisPaintDeviceSP src, const QPoint& srcTopL
KisPaintDeviceSP interm = KisPaintDeviceSP(new KisPaintDevice(*src));
KoColorSpace * cs = src->colorSpace();
KoConvolutionOp * convolutionOp = cs->convolutionOp();
QBitArray channelFlags = cs->channelFlags(); // Only convolve color channels
KisConvolutionPainter painter( interm );
painter.beginTransaction("bouuh");
painter.setChannelFlags( channelFlags );
painter.beginTransaction("bouuh"); // XXX: What's this? Someone
// doing a Niobe impersonation?
painter.applyMatrix(kernel, srcTopLeft.x(), srcTopLeft.y(), areaSize.width(), areaSize.height(), BORDER_REPEAT);
if (painter.cancelRequested()) {
......@@ -95,14 +99,12 @@ void KisUnsharpFilter::process(const KisPaintDeviceSP src, const QPoint& srcTopL
int pixelsProcessed = 0;
qint32 weights[2];
/* weights[0] = 128;
qint32 factor = (quint32) 128 / amount;
weights[1] = (factor - 128);*/
qint32 factor = 128;
// XXX: Added static cast to avoid warning
weights[0] = static_cast<qint32>(factor * ( 1. + amount));
weights[1] = static_cast<qint32>(-factor * amount);
// kDebug() << (int) weights[0] << " " << (int)weights[1] << " " << factor << endl;
for( int j = 0; j < areaSize.height(); j++)
{
while( ! srcIt.isDone() )
......@@ -114,7 +116,7 @@ void KisUnsharpFilter::process(const KisPaintDeviceSP src, const QPoint& srcTopL
{
memcpy(colors[0],srcIt.rawData(), cdepth);
memcpy(colors[1],intermIt.rawData(), cdepth);
cs->convolveColors(colors, weights, KoChannelInfo::FLAG_COLOR, dstIt.rawData(), factor, 0, 2 );
convolutionOp->convolveColors(colors, weights, dstIt.rawData(), factor, 0, 2, channelFlags );
}
}
setProgress(++pixelsProcessed);
......
......@@ -149,7 +149,7 @@ void KisToolColorPicker::mousePressEvent(KoPointerEvent *event)
}
// Weird, I can't do that directly :/
const quint8** cpixels = const_cast<const quint8**>(pixels);
cs->mixColors(cpixels, weights, counts[m_radius], data);
cs->mixColorsOp()->mixColors(cpixels, weights, counts[m_radius], data);
m_pickedColor = KoColor(data, cs);
for (i = 0; i < counts[m_radius]; i++)
......
......@@ -724,8 +724,8 @@ void KisSelectionManager::feather()
// Make sure we've got enough space around the edges.
rect = QRect(rect.x() - 3, rect.y() - 3, rect.width() + 6, rect.height() + 6);
rect &= QRect(0, 0, img->width(), img->height());
painter.applyMatrix(k, rect.x(), rect.y(), rect.width(), rect.height(), BORDER_AVOID, KoChannelInfo::FLAG_ALPHA);
painter.setChannelFlags( selection->colorSpace()->channelFlags( false, true, false, false ) );
painter.applyMatrix(k, rect.x(), rect.y(), rect.width(), rect.height(), BORDER_AVOID);
painter.end();
dev->setDirty();
......
......@@ -66,6 +66,8 @@ void KoColorSlider::drawContents( QPainter *painter )
colors[0] = m_minColor.data();
colors[1] = m_maxColor.data();
KoMixColorsOp * mixOp = c.colorSpace()->mixColorsOp();
QImage image(contentsRect().width(), contentsRect().height(), QImage::Format_ARGB32 );
if( orientation() == Qt::Horizontal ) {
......@@ -77,7 +79,7 @@ void KoColorSlider::drawContents( QPainter *painter )
colorWeights[0] = static_cast<quint8>((1.0 - t) * 255 + 0.5);
colorWeights[1] = 255 - colorWeights[0];
c.colorSpace()->mixColors(colors, colorWeights, 2, c.data());
mixOp->mixColors(colors, colorWeights, 2, c.data());
c.toQColor(&color, &opacity);
color.setAlpha(opacity);
......@@ -95,7 +97,7 @@ void KoColorSlider::drawContents( QPainter *painter )
colorWeights[0] = static_cast<quint8>((t) * 255 + 0.5);
colorWeights[1] = 255 - colorWeights[0];
c.colorSpace()->mixColors(colors, colorWeights, 2, c.data());
mixOp->mixColors(colors, colorWeights, 2, c.data());
c.toQColor(&color, &opacity);
color.setAlpha(opacity);
......
......@@ -52,6 +52,7 @@ void KoXYColorSelector::drawContents( QPainter *painter )
colors[3] = m_colors[3].data();
QImage image(contentsRect().width(), contentsRect().height(), QImage::Format_ARGB32 );
KoMixColorsOp * mixOp = m_colorSpace->mixColorsOp();
for (int x = 0; x < contentsRect().width(); x++)
for (int y = 0; y < contentsRect().height(); y++){
......@@ -65,7 +66,7 @@ void KoXYColorSelector::drawContents( QPainter *painter )
colorWeights[2] = static_cast<quint8>((yVal) * (1.0 - xVal) * 255 + 0.5);
colorWeights[3] = static_cast<quint8>((yVal) * (xVal) * 255 + 0.5);
m_colorSpace->mixColors(colors, colorWeights, 4, c.data());
mixOp->mixColors(colors, colorWeights, 4, c.data());
c.toQColor( &color);
......
......@@ -23,9 +23,9 @@
#include "qstring.h"
#include "ksharedptr.h"
/**
/**
* This class gives some basic information about a channel,
* that is, one of the components that makes up a particular
* that is, one of the components that makes up a particular
* pixel.
*/
class KoChannelInfo : public KShared {
......@@ -48,12 +48,6 @@ public:
INT16,
OTHER ///< Use this if the channel is neither an integer or a float
};
enum enumChannelFlags {
FLAG_COLOR = 1,
FLAG_ALPHA = (1 << 1),
FLAG_SUBSTANCE = (1 << 2),
FLAG_SUBSTRATE = (1 << 3)
};
public:
KoChannelInfo() { };
......@@ -64,12 +58,12 @@ public:
* User-friendly name for this channel for presentation purposes in the gui
*/
inline QString name() const { return m_name; };
/**
/**
* returns the position of the first byte of the channel in the pixel
*/
inline qint32 pos() const { return m_pos; };
/**
* returns the number of bytes this channel takes
*/
......
......@@ -18,9 +18,10 @@
*/
#include <QThreadStorage>
#include <QByteArray>
#include <QBitArray>
#include "KoColorSpace.h"
#include "KoChannelInfo.h"
#include <kdebug.h>
#include "KoCompositeOp.h"
......@@ -76,6 +77,22 @@ Q3ValueVector<KoChannelInfo *> KoColorSpace::channels() const
return d->channels;
}
QBitArray KoColorSpace::channelFlags(bool color, bool alpha, bool substance, bool substrate) const
{
QBitArray ba( d->channels.size() );
if ( !color && !alpha && !substance && !substrate ) return ba;
for ( int i = 0; i < d->channels.size(); ++i ) {
KoChannelInfo * channel = d->channels.at( i );
if ( ( color && channel->channelType() == KoChannelInfo::COLOR ) ||
( alpha && channel->channelType() == KoChannelInfo::ALPHA ) ||
( substrate && channel->channelType() == KoChannelInfo::SUBSTRATE ) ||
( substance && channel->channelType() == KoChannelInfo::SUBSTANCE ) )
ba.setBit( i, true );
}
return ba;
}
void KoColorSpace::addChannel(KoChannelInfo * ci)
{
d->channels.push_back(ci);
......@@ -91,21 +108,11 @@ QList<KoCompositeOp*> KoColorSpace::userVisiblecompositeOps() const
return d->compositeOps.values();
}
void KoColorSpace::mixColors(const quint8 **colors, const quint8 *weights, quint32 nColors, quint8 *dst) const
{
Q_ASSERT(d->mixColorsOp);
d->mixColorsOp->mixColors(colors, weights, nColors, dst);
}