Commit df8c4631 authored by Boudewijn Rempt's avatar Boudewijn Rempt

Replace the blackpoint compensation bool with QFlags

Also remove all the default parameter values; let's make it explicit when
we are pulling a conversion paramater out of thin air instead of asking
the user what she wants.
parent 86d4a1ff
......@@ -34,13 +34,13 @@ KisColorSpaceConvertVisitor::KisColorSpaceConvertVisitor(KisImageWSP image,
const KoColorSpace *srcColorSpace,
const KoColorSpace *dstColorSpace,
KoColorConversionTransformation::Intent renderingIntent,
bool blackpointCompensation)
KoColorConversionTransformation::ConversionFlags conversionFlags)
: KisNodeVisitor()
, m_image(image)
, m_srcColorSpace(srcColorSpace)
, m_dstColorSpace(dstColorSpace)
, m_renderingIntent(renderingIntent)
, m_blackpointCompensation(blackpointCompensation)
, m_conversionFlags(conversionFlags)
{
}
......@@ -112,7 +112,7 @@ bool KisColorSpaceConvertVisitor::convertPaintDevice(KisLayer* layer)
m_image->undoAdapter()->addCommand(propsCommand);
if (layer->original()) {
KUndo2Command* cmd = layer->original()->convertTo(m_dstColorSpace, m_renderingIntent, m_blackpointCompensation);
KUndo2Command* cmd = layer->original()->convertTo(m_dstColorSpace, m_renderingIntent, m_conversionFlags);
if (cmd)
m_image->undoAdapter()->addCommand(cmd);
else
......@@ -120,7 +120,7 @@ bool KisColorSpaceConvertVisitor::convertPaintDevice(KisLayer* layer)
}
if (layer->paintDevice()) {
KUndo2Command* cmd = layer->paintDevice()->convertTo(m_dstColorSpace, m_renderingIntent, m_blackpointCompensation);
KUndo2Command* cmd = layer->paintDevice()->convertTo(m_dstColorSpace, m_renderingIntent, m_conversionFlags);
if (cmd)
m_image->undoAdapter()->addCommand(cmd);
else
......@@ -128,7 +128,7 @@ bool KisColorSpaceConvertVisitor::convertPaintDevice(KisLayer* layer)
}
if (layer->projection()) {
KUndo2Command* cmd = layer->projection()->convertTo(m_dstColorSpace, m_renderingIntent, m_blackpointCompensation);
KUndo2Command* cmd = layer->projection()->convertTo(m_dstColorSpace, m_renderingIntent, m_conversionFlags);
if (cmd)
m_image->undoAdapter()->addCommand(cmd);
else
......
......@@ -38,7 +38,7 @@ public:
const KoColorSpace *srcColorSpace,
const KoColorSpace *dstColorSpace,
KoColorConversionTransformation::Intent renderingIntent,
bool blackpointCompensation);
KoColorConversionTransformation::ConversionFlags conversionFlags);
virtual ~KisColorSpaceConvertVisitor();
public:
......@@ -73,7 +73,7 @@ private:
const KoColorSpace *m_srcColorSpace;
const KoColorSpace *m_dstColorSpace;
KoColorConversionTransformation::Intent m_renderingIntent;
bool m_blackpointCompensation;
KoColorConversionTransformation::ConversionFlags m_conversionFlags;
QBitArray m_emptyChannelFlags;
};
......
......@@ -82,7 +82,9 @@ quint8* KisFixedPaintDevice::data() const
return const_cast<quint8*>(m_data.data());
}
void KisFixedPaintDevice::convertTo(const KoColorSpace* dstColorSpace, KoColorConversionTransformation::Intent renderingIntent, bool blackpointCompensation)
void KisFixedPaintDevice::convertTo(const KoColorSpace* dstColorSpace,
KoColorConversionTransformation::Intent renderingIntent,
KoColorConversionTransformation::ConversionFlags conversionFlags)
{
if (*m_colorSpace == *dstColorSpace) {
return;
......@@ -94,7 +96,7 @@ void KisFixedPaintDevice::convertTo(const KoColorSpace* dstColorSpace, KoColorCo
dstColorSpace,
size,
renderingIntent,
blackpointCompensation);
conversionFlags);
m_colorSpace = dstColorSpace;
m_data = dstData;
......@@ -117,7 +119,7 @@ void KisFixedPaintDevice::convertFromQImage(const QImage& _image, const QString
} else {
KoColorSpaceRegistry::instance()
->colorSpace( RGBAColorModelID.id(), Integer8BitsColorDepthID.id(), srcProfileName)
->convertPixelsTo(image.bits(), data(), colorSpace(), image.width() * image.height());
->convertPixelsTo(image.bits(), data(), colorSpace(), image.width() * image.height(), KoColorConversionTransformation::IntentPerceptual, KoColorConversionTransformation::BlackpointCompensation);
}
}
......@@ -148,7 +150,7 @@ QImage KisFixedPaintDevice::convertToQImage(const KoColorProfile * dstProfile,
if (QRect(x1, y1, w, h) == m_bounds) {
return colorSpace()->convertToQImage(data(), w, h, dstProfile,
KoColorConversionTransformation::IntentPerceptual);
KoColorConversionTransformation::IntentPerceptual, KoColorConversionTransformation::BlackpointCompensation);
} else {
int pSize = pixelSize();
int deviceWidth = m_bounds.width();
......@@ -161,8 +163,7 @@ QImage KisFixedPaintDevice::convertToQImage(const KoColorProfile * dstProfile,
srcPtr += deviceWidth * pSize;
dstPtr += w * pSize;
}
QImage image = colorSpace()->convertToQImage(newData, w, h, dstProfile,
KoColorConversionTransformation::IntentPerceptual);
QImage image = colorSpace()->convertToQImage(newData, w, h, dstProfile, KoColorConversionTransformation::IntentPerceptual, KoColorConversionTransformation::BlackpointCompensation);
return image;
}
}
......
......@@ -108,8 +108,8 @@ public:
* Converts the paint device to a different colorspace
*/
void convertTo(const KoColorSpace * dstColorSpace,
KoColorConversionTransformation::Intent renderingIntent = KoColorConversionTransformation::IntentPerceptual,
bool blackpointCompensation = false);
KoColorConversionTransformation::Intent renderingIntent,
KoColorConversionTransformation::ConversionFlags conversionFlags);
/**
* Fill this paint device with the data from image
......
......@@ -151,7 +151,7 @@ void KisGroupLayer::resetCache(const KoColorSpace *colorSpace)
dev->setX(m_d->x);
dev->setY(m_d->y);
quint8* defaultPixel = colorSpace->allocPixelBuffer(1);
colorSpace->convertPixelsTo(m_d->paintDevice->defaultPixel(), defaultPixel, colorSpace, 1);
colorSpace->convertPixelsTo(m_d->paintDevice->defaultPixel(), defaultPixel, colorSpace, 1, KoColorConversionTransformation::IntentPerceptual, KoColorConversionTransformation::BlackpointCompensation);
dev->setDefaultPixel(defaultPixel);
delete[] defaultPixel;
m_d->paintDevice = dev;
......
......@@ -690,7 +690,9 @@ void KisImage::shear(double angleX, double angleY)
angleX, angleY, QPointF());
}
void KisImage::convertImageColorSpace(const KoColorSpace *dstColorSpace, KoColorConversionTransformation::Intent renderingIntent, bool blackpointCompensation)
void KisImage::convertImageColorSpace(const KoColorSpace *dstColorSpace,
KoColorConversionTransformation::Intent renderingIntent,
KoColorConversionTransformation::ConversionFlags conversionFlags)
{
if (*m_d->colorSpace == *dstColorSpace) return;
......@@ -700,7 +702,7 @@ void KisImage::convertImageColorSpace(const KoColorSpace *dstColorSpace, KoColor
undoAdapter()->addCommand(new KisImageLockCommand(KisImageWSP(this), true));
undoAdapter()->addCommand(new KisImageSetProjectionColorSpaceCommand(KisImageWSP(this), dstColorSpace));
KisColorSpaceConvertVisitor visitor(this, srcColorSpace, dstColorSpace, renderingIntent, blackpointCompensation);
KisColorSpaceConvertVisitor visitor(this, srcColorSpace, dstColorSpace, renderingIntent, conversionFlags);
m_d->rootLayer->accept(visitor);
undoAdapter()->addCommand(new KisImageLockCommand(KisImageWSP(this), false));
......@@ -1062,7 +1064,7 @@ QImage KisImage::convertToQImage(qint32 x,
{
KisPaintDeviceSP dev = m_d->rootLayer->projection();
if (!dev) return QImage();
QImage image = dev->convertToQImage(const_cast<KoColorProfile*>(profile), x, y, w, h);
QImage image = dev->convertToQImage(const_cast<KoColorProfile*>(profile), x, y, w, h, KoColorConversionTransformation::IntentPerceptual, KoColorConversionTransformation::BlackpointCompensation);
if (m_d->backgroundPattern) {
m_d->backgroundPattern->paintBackground(image, QRect(x, y, w, h));
......@@ -1143,7 +1145,7 @@ QImage KisImage::convertToQImage(const QRect& scaledRect, const QSize& scaledIma
}
delete [] imageRow;
QImage image = colorSpace()->convertToQImage(scaledImageData, scaledRect.width(), scaledRect.height(), const_cast<KoColorProfile*>(profile), KoColorConversionTransformation::IntentPerceptual);
QImage image = colorSpace()->convertToQImage(scaledImageData, scaledRect.width(), scaledRect.height(), const_cast<KoColorProfile*>(profile), KoColorConversionTransformation::IntentPerceptual, KoColorConversionTransformation::BlackpointCompensation);
if (m_d->backgroundPattern) {
m_d->backgroundPattern->paintBackground(image, scaledRect, scaledImageSize, QSize(imageWidth, imageHeight));
......
......@@ -227,7 +227,9 @@ public:
/**
* Convert the image and all its layers to the dstColorSpace
*/
void convertImageColorSpace(const KoColorSpace *dstColorSpace, KoColorConversionTransformation::Intent renderingIntent = KoColorConversionTransformation::IntentPerceptual, bool blackpointCompensation = false);
void convertImageColorSpace(const KoColorSpace *dstColorSpace,
KoColorConversionTransformation::Intent renderingIntent,
KoColorConversionTransformation::ConversionFlags conversionFlags);
/**
* Set the color space of the projection (and the root layer)
......
......@@ -521,7 +521,7 @@ QImage KisLayer::createThumbnail(qint32 w, qint32 h)
KisPaintDeviceSP originalDevice = original();
return originalDevice ?
originalDevice->createThumbnail(w, h) : QImage();
originalDevice->createThumbnail(w, h, KoColorConversionTransformation::IntentPerceptual, KoColorConversionTransformation::BlackpointCompensation) : QImage();
}
qint32 KisLayer::x() const
......
......@@ -293,7 +293,7 @@ QImage KisMask::createThumbnail(qint32 w, qint32 h)
selection() ? selection()->projection() : 0;
return originalDevice ?
originalDevice->createThumbnail(w, h) : QImage();
originalDevice->createThumbnail(w, h, KoColorConversionTransformation::IntentPerceptual, KoColorConversionTransformation::BlackpointCompensation) : QImage();
}
#include "kis_mask.moc"
......@@ -112,7 +112,7 @@ public:
}
QImage createThumbnail(qint32 w, qint32 h, KoColorConversionTransformation::Intent renderingIntent, bool blackpointCompensation) {
QImage createThumbnail(qint32 w, qint32 h, KoColorConversionTransformation::Intent renderingIntent, KoColorConversionTransformation::ConversionFlags conversionFlags) {
QImage thumbnail;
if(m_data->m_thumbnailsValid) {
......@@ -124,7 +124,7 @@ public:
}
if(thumbnail.isNull()) {
thumbnail = m_paintDevice->createThumbnail(w, h, QRect(), renderingIntent, blackpointCompensation);
thumbnail = m_paintDevice->createThumbnail(w, h, QRect(), renderingIntent, conversionFlags);
cacheThumbnail(w, h, thumbnail);
}
......@@ -559,10 +559,10 @@ bool KisPaintDevice::read(KoStore *store)
return retval;
}
KUndo2Command* KisPaintDevice::convertTo(const KoColorSpace * dstColorSpace, KoColorConversionTransformation::Intent renderingIntent, bool blackpointCompensation)
KUndo2Command* KisPaintDevice::convertTo(const KoColorSpace * dstColorSpace, KoColorConversionTransformation::Intent renderingIntent, KoColorConversionTransformation::ConversionFlags conversionFlags)
{
m_d->cache.invalidate();
dbgImage << this << colorSpace()->id() << dstColorSpace->id() << renderingIntent << blackpointCompensation;
dbgImage << this << colorSpace()->id() << dstColorSpace->id() << renderingIntent << conversionFlags;
if (*colorSpace() == *dstColorSpace) {
return 0;
}
......@@ -598,7 +598,7 @@ KUndo2Command* KisPaintDevice::convertTo(const KoColorSpace * dstColorSpace, KoC
const quint8 *srcData = srcIt->oldRawData();
quint8 *dstData = dstIt->rawData();
m_d->colorSpace->convertPixelsTo(srcData, dstData, dstColorSpace, columns, renderingIntent, blackpointCompensation);
m_d->colorSpace->convertPixelsTo(srcData, dstData, dstColorSpace, columns, renderingIntent, conversionFlags);
column += columns;
columnsRemaining -= columns;
......@@ -660,7 +660,7 @@ void KisPaintDevice::convertFromQImage(const QImage& _image, const KoColorProfil
quint8 * dstData = new quint8[image.width() * image.height() * pixelSize()];
KoColorSpaceRegistry::instance()
->colorSpace(RGBAColorModelID.id(), Integer8BitsColorDepthID.id(), profile)
->convertPixelsTo(image.bits(), dstData, colorSpace(), image.width() * image.height());
->convertPixelsTo(image.bits(), dstData, colorSpace(), image.width() * image.height(), KoColorConversionTransformation::IntentPerceptual, KoColorConversionTransformation::BlackpointCompensation);
writeBytes(dstData, offsetX, offsetY, image.width(), image.height());
delete[] dstData;
......@@ -668,7 +668,7 @@ void KisPaintDevice::convertFromQImage(const QImage& _image, const KoColorProfil
m_d->cache.invalidate();
}
QImage KisPaintDevice::convertToQImage(const KoColorProfile *dstProfile, KoColorConversionTransformation::Intent renderingIntent, bool blackpointCompensation) const
QImage KisPaintDevice::convertToQImage(const KoColorProfile *dstProfile, KoColorConversionTransformation::Intent renderingIntent, KoColorConversionTransformation::ConversionFlags conversionFlags) const
{
qint32 x1;
qint32 y1;
......@@ -684,10 +684,10 @@ QImage KisPaintDevice::convertToQImage(const KoColorProfile *dstProfile, KoColor
w = rc.width();
h = rc.height();
return convertToQImage(dstProfile, x1, y1, w, h, renderingIntent, blackpointCompensation);
return convertToQImage(dstProfile, x1, y1, w, h, renderingIntent, conversionFlags);
}
QImage KisPaintDevice::convertToQImage(const KoColorProfile * dstProfile, qint32 x1, qint32 y1, qint32 w, qint32 h, KoColorConversionTransformation::Intent renderingIntent, bool blackpointCompensation) const
QImage KisPaintDevice::convertToQImage(const KoColorProfile * dstProfile, qint32 x1, qint32 y1, qint32 w, qint32 h, KoColorConversionTransformation::Intent renderingIntent, KoColorConversionTransformation::ConversionFlags conversionFlags) const
{
if (w < 0)
......@@ -709,7 +709,7 @@ QImage KisPaintDevice::convertToQImage(const KoColorProfile * dstProfile, qint3
// XXX: Is this really faster than converting line by line and building the QImage directly?
// This copies potentially a lot of data.
readBytes(data, x1, y1, w, h);
QImage image = colorSpace()->convertToQImage(data, w, h, dstProfile, renderingIntent, blackpointCompensation);
QImage image = colorSpace()->convertToQImage(data, w, h, dstProfile, renderingIntent, conversionFlags);
delete[] data;
return image;
......@@ -761,16 +761,16 @@ KisPaintDeviceSP KisPaintDevice::createThumbnailDevice(qint32 w, qint32 h, QRect
}
QImage KisPaintDevice::createThumbnail(qint32 w, qint32 h, QRect rect, KoColorConversionTransformation::Intent renderingIntent, bool blackpointCompensation)
QImage KisPaintDevice::createThumbnail(qint32 w, qint32 h, QRect rect, KoColorConversionTransformation::Intent renderingIntent, KoColorConversionTransformation::ConversionFlags conversionFlags)
{
KisPaintDeviceSP dev = createThumbnailDevice(w, h, rect);
QImage thumbnail = dev->convertToQImage(KoColorSpaceRegistry::instance()->rgb8()->profile(), renderingIntent, blackpointCompensation);
QImage thumbnail = dev->convertToQImage(KoColorSpaceRegistry::instance()->rgb8()->profile(), renderingIntent, conversionFlags);
return thumbnail;
}
QImage KisPaintDevice::createThumbnail(qint32 w, qint32 h, KoColorConversionTransformation::Intent renderingIntent, bool blackpointCompensation)
QImage KisPaintDevice::createThumbnail(qint32 w, qint32 h, KoColorConversionTransformation::Intent renderingIntent, KoColorConversionTransformation::ConversionFlags conversionFlags)
{
return m_d->cache.createThumbnail(w, h, renderingIntent, blackpointCompensation);
return m_d->cache.createThumbnail(w, h, renderingIntent, conversionFlags);
}
KisHLineIteratorSP KisPaintDevice::createHLineIteratorNG(qint32 x, qint32 y, qint32 w)
......
......@@ -406,7 +406,7 @@ public:
*
* @return a command that can be used to undo the conversion.
*/
KUndo2Command* convertTo(const KoColorSpace * dstColorSpace, KoColorConversionTransformation::Intent renderingIntent = KoColorConversionTransformation::IntentPerceptual, bool blackpointCompensation = false);
KUndo2Command* convertTo(const KoColorSpace * dstColorSpace, KoColorConversionTransformation::Intent renderingIntent, KoColorConversionTransformation::ConversionFlags conversionFlags);
/**
* Changes the profile of the colorspace of this paint device to the given
......@@ -431,7 +431,7 @@ public:
* case it's up to the color strategy to choose a profile (most
* like sRGB).
*/
virtual QImage convertToQImage(const KoColorProfile *dstProfile, qint32 x, qint32 y, qint32 w, qint32 h, KoColorConversionTransformation::Intent renderingIntent = KoColorConversionTransformation::IntentPerceptual, bool blackpointCompensation = false) const;
virtual QImage convertToQImage(const KoColorProfile *dstProfile, qint32 x, qint32 y, qint32 w, qint32 h, KoColorConversionTransformation::Intent renderingIntent, KoColorConversionTransformation::ConversionFlags conversionFlags) const;
/**
* Create an RGBA QImage from a rectangle in the paint device. The
......@@ -441,7 +441,7 @@ public:
* case it's up to the color strategy to choose a profile (most
* like sRGB).
*/
virtual QImage convertToQImage(const KoColorProfile * dstProfile, KoColorConversionTransformation::Intent renderingIntent = KoColorConversionTransformation::IntentPerceptual, bool blackpointCompensation = false) const;
virtual QImage convertToQImage(const KoColorProfile * dstProfile, KoColorConversionTransformation::Intent renderingIntent, KoColorConversionTransformation::ConversionFlags conversionFlags) const;
/**
* Creates a paint device thumbnail of the paint device, retaining
......@@ -465,12 +465,12 @@ public:
* @param maxh: maximum height
* @param rect: only this rect will be used for the thumbnail
*/
virtual QImage createThumbnail(qint32 maxw, qint32 maxh, QRect rect, KoColorConversionTransformation::Intent renderingIntent = KoColorConversionTransformation::IntentPerceptual, bool blackpointCompensation = false);
virtual QImage createThumbnail(qint32 maxw, qint32 maxh, QRect rect, KoColorConversionTransformation::Intent renderingIntent, KoColorConversionTransformation::ConversionFlags conversionFlags);
/**
* Cached version of createThumbnail(qint32 maxw, qint32 maxh, const KisSelection *selection, QRect rect)
*/
virtual QImage createThumbnail(qint32 maxw, qint32 maxh, KoColorConversionTransformation::Intent renderingIntent = KoColorConversionTransformation::IntentPerceptual, bool blackpointCompensation = false);
virtual QImage createThumbnail(qint32 maxw, qint32 maxh, KoColorConversionTransformation::Intent renderingIntent, KoColorConversionTransformation::ConversionFlags conversionFlags);
/**
* Fill c and opacity with the values found at x and y.
......
......@@ -701,7 +701,7 @@ public:
/**
* set the blackpoint compensation flag in case pixels need to be converted before painting
* set the conversion flags in case pixels need to be converted before painting
*/
......
......@@ -266,7 +266,7 @@ QImage KisSelectionBasedLayer::createThumbnail(qint32 w, qint32 h)
KisPaintDeviceSP originalDevice = original();
return originalDevice && originalSelection ?
originalDevice->createThumbnail(w, h) :
originalDevice->createThumbnail(w, h, KoColorConversionTransformation::IntentPerceptual, KoColorConversionTransformation::BlackpointCompensation) :
QImage();
}
......
......@@ -36,7 +36,9 @@ struct KoCtlColorConversionTransformation::Private {
bool srcIsCTL;
};
KoCtlColorConversionTransformation::KoCtlColorConversionTransformation(const KoColorSpace* srcCs, const KoColorSpace* dstCs) : KoColorConversionTransformation(srcCs, dstCs), d(new Private)
KoCtlColorConversionTransformation::KoCtlColorConversionTransformation(const KoColorSpace* srcCs, const KoColorSpace* dstCs)
: KoColorConversionTransformation(srcCs, dstCs, KoColorConversionTransformation::IntentPerceptual, KoColorConversionTransformation::BlackpointCompensation)
, d(new Private)
{
dbgPigment << "init KoCtlColorConversionTransformation " << srcCs->id() << " and " << dstCs->id();
d->program = 0;
......@@ -93,10 +95,10 @@ KoCtlColorConversionTransformationFactory::KoCtlColorConversionTransformationFac
{
}
KoColorConversionTransformation* KoCtlColorConversionTransformationFactory::createColorTransformation(const KoColorSpace* srcColorSpace, const KoColorSpace* dstColorSpace, KoColorConversionTransformation::Intent renderingIntent, bool blackpointCompensation) const
KoColorConversionTransformation* KoCtlColorConversionTransformationFactory::createColorTransformation(const KoColorSpace* srcColorSpace, const KoColorSpace* dstColorSpace, KoColorConversionTransformation::Intent renderingIntent, KoColorConversionTransformation::ConversionFlags conversionFlags) const
{
Q_UNUSED(renderingIntent);
Q_UNUSED(blackpointCompensation);
Q_UNUSED(conversionFlags);
Q_ASSERT(canBeSource(srcColorSpace));
Q_ASSERT(canBeDestination(dstColorSpace));
dbgPigment << "Creating transformation from " << srcColorSpace->id() << " to " << dstColorSpace->id();
......
......@@ -40,7 +40,7 @@ class PIGMENTCMS_EXPORT KoCtlColorConversionTransformationFactory : public KoCol
public:
KoCtlColorConversionTransformationFactory(QString _srcModelId, QString _srcDepthId, QString _srcProfile, QString _dstModelId, QString _dstDepthId, QString _dstProfile);
virtual ~KoCtlColorConversionTransformationFactory();
virtual KoColorConversionTransformation* createColorTransformation(const KoColorSpace* srcColorSpace, const KoColorSpace* dstColorSpace, KoColorConversionTransformation::Intent renderingIntent = KoColorConversionTransformation::IntentPerceptual, bool blackpointCompensation = false) const;
virtual KoColorConversionTransformation* createColorTransformation(const KoColorSpace* srcColorSpace, const KoColorSpace* dstColorSpace, KoColorConversionTransformation::Intent renderingIntent, KoColorConversionTransformation::ConversionFlags conversionFlags) const;
virtual bool conserveColorInformation() const;
virtual bool conserveDynamicRange() const;
private:
......
......@@ -103,7 +103,9 @@ void ColorSpaceConversion::slotImageColorSpaceConversion()
const KoColorSpace * cs = dlgColorSpaceConversion->m_page->colorSpaceSelector->currentColorSpace();
QApplication::setOverrideCursor(KisCursor::waitCursor());
image->convertImageColorSpace(cs, (KoColorConversionTransformation::Intent)dlgColorSpaceConversion->m_intentButtonGroup.checkedId(), dlgColorSpaceConversion->m_page->chkBlackpointCompensation->isChecked());
KoColorConversionTransformation::ConversionFlags conversionFlags;
if (dlgColorSpaceConversion->m_page->chkBlackpointCompensation->isChecked()) conversionFlags |= KoColorConversionTransformation::BlackpointCompensation;
image->convertImageColorSpace(cs, (KoColorConversionTransformation::Intent)dlgColorSpaceConversion->m_intentButtonGroup.checkedId(), conversionFlags);
QApplication::restoreOverrideCursor();
}
delete dlgColorSpaceConversion;
......@@ -131,7 +133,9 @@ void ColorSpaceConversion::slotLayerColorSpaceConversion()
image->undoAdapter()->beginMacro(i18n("Convert Layer Type"));
KisColorSpaceConvertVisitor visitor(image, layer->colorSpace(), cs, (KoColorConversionTransformation::Intent)dlgColorSpaceConversion->m_intentButtonGroup.checkedId(), dlgColorSpaceConversion->m_page->chkBlackpointCompensation->isChecked() );
KoColorConversionTransformation::ConversionFlags conversionFlags;
if (dlgColorSpaceConversion->m_page->chkBlackpointCompensation->isChecked()) conversionFlags |= KoColorConversionTransformation::BlackpointCompensation;
KisColorSpaceConvertVisitor visitor(image, layer->colorSpace(), cs, (KoColorConversionTransformation::Intent)dlgColorSpaceConversion->m_intentButtonGroup.checkedId(), conversionFlags);
layer->accept(visitor);
image->undoAdapter()->endMacro();
......
......@@ -63,7 +63,7 @@ DlgColorSpaceConversion::DlgColorSpaceConversion(QWidget * parent,
}
bool blackpointCompensation();
DlgColorSpaceConversion::~DlgColorSpaceConversion()
{
......
......@@ -137,7 +137,7 @@ void KisCommonColors::recalculate()
KisImageWSP kisImage = m_canvas->image();
QImage image = kisImage->projection()->createThumbnail(1024, 1024, kisImage->bounds());
QImage image = kisImage->projection()->createThumbnail(1024, 1024, kisImage->bounds(), KoColorConversionTransformation::IntentPerceptual, KoColorConversionTransformation::BlackpointCompensation);
KisCommonColorsRecalculationRunner* runner = new KisCommonColorsRecalculationRunner(image, patchCount(), this);
QThreadPool::globalInstance()->start(runner);
......
......@@ -234,7 +234,7 @@ void KisUndoModel::addImage(int idx) {
if( m_stack->count() == idx && !imageMap.contains(currentCommand)) {
KisImageWSP historyImage = m_canvas->view()->image();
KisPaintDeviceSP paintDevice = historyImage->projection();
QImage image = paintDevice->createThumbnail(32, 32);
QImage image = paintDevice->createThumbnail(32, 32, KoColorConversionTransformation::IntentPerceptual, KoColorConversionTransformation::BlackpointCompensation);
imageMap[currentCommand] = image;
}
QList<const KUndo2Command*> list;
......
......@@ -102,7 +102,7 @@ void KisFilterFastColorTransfer::process(KisPaintDeviceSP device,
const KoColorSpace* oldCS = device->colorSpace();
KisPaintDeviceSP srcLAB = new KisPaintDevice(*device.data());
dbgPlugins << "srcLab : " << srcLAB->extent();
KUndo2Command* cmd = srcLAB->convertTo(labCS);
KUndo2Command* cmd = srcLAB->convertTo(labCS, KoColorConversionTransformation::IntentPerceptual, KoColorConversionTransformation::BlackpointCompensation);
delete cmd;
if (progressUpdater) {
......
......@@ -92,7 +92,7 @@ KisPropertiesConfiguration* KisWdgFastColorTransfer::configuration() const
}
dbgPlugins << "convert ref to lab";
KUndo2Command* cmd = ref->convertTo(labCS);
KUndo2Command* cmd = ref->convertTo(labCS, KoColorConversionTransformation::IntentPerceptual, KoColorConversionTransformation::BlackpointCompensation);
delete cmd;
// Compute the means and sigmas of ref
......
......@@ -148,7 +148,7 @@ void KisFilterPhongBumpmap::process(KisPaintDeviceSP device,
KisPaintDeviceSP bumpmapPaintDevice = new KisPaintDevice(KoColorSpaceRegistry::instance()->rgb16());
bumpmapPaintDevice->writeBytes(bumpmap.data(), outputArea.x(), outputArea.y(), outputArea.width(), outputArea.height());
KUndo2Command *leaker = bumpmapPaintDevice->convertTo(device->colorSpace());
KUndo2Command *leaker = bumpmapPaintDevice->convertTo(device->colorSpace(), KoColorConversionTransformation::IntentPerceptual, KoColorConversionTransformation::BlackpointCompensation);
KisPainter copier(device);
copier.bitBlt(outputArea.x(), outputArea.y(), bumpmapPaintDevice,
outputArea.x(), outputArea.y(), outputArea.width(), outputArea.height());
......
......@@ -75,7 +75,7 @@ KoFilter::ConversionStatus KisBMPExport::convert(const QByteArray& from, const Q
QRect rc = output->image()->bounds();
output->image()->refreshGraph();
output->image()->lock();
QImage image = output->image()->projection()->convertToQImage(0, 0, 0, rc.width(), rc.height());
QImage image = output->image()->projection()->convertToQImage(0, 0, 0, rc.width(), rc.height(), KoColorConversionTransformation::IntentPerceptual, KoColorConversionTransformation::BlackpointCompensation);
output->image()->unlock();
image.save(url.toLocalFile());
return KoFilter::OK;
......
......@@ -211,7 +211,7 @@ KisImageBuilder_Result KisJPEGConverter::decode(const KUrl& uri)
KoColorTransformation* transform = 0;
if (profile && !profile->isSuitableForOutput()) {
transform = KoColorSpaceRegistry::instance()->colorSpace(modelId, Integer8BitsColorDepthID.id(), profile)->createColorConverter(cs);
transform = KoColorSpaceRegistry::instance()->colorSpace(modelId, Integer8BitsColorDepthID.id(), profile)->createColorConverter(cs, KoColorConversionTransformation::IntentPerceptual, KoColorConversionTransformation::BlackpointCompensation);
}
// Apparently an invalid transform was created from the profile. See bug https://bugs.kde.org/show_bug.cgi?id=255451.
// After 2.3: warn the user!
......@@ -463,7 +463,7 @@ KisImageBuilder_Result KisJPEGConverter::buildFile(const KUrl& uri, KisPaintLaye
const KoColorSpace * cs = layer->colorSpace();
J_COLOR_SPACE color_type = getColorTypeforColorSpace(cs);
if (color_type == JCS_UNKNOWN) {
KUndo2Command *tmp = layer->paintDevice()->convertTo(KoColorSpaceRegistry::instance()->rgb8());
KUndo2Command *tmp = layer->paintDevice()->convertTo(KoColorSpaceRegistry::instance()->rgb8(), KoColorConversionTransformation::IntentPerceptual, KoColorConversionTransformation::BlackpointCompensation);
delete tmp;
color_type = JCS_RGB;
}
......
......@@ -193,10 +193,10 @@ KoFilter::ConversionStatus KisPPMExport::convert(const QByteArray& from, const Q
if (((rgb && (pd->colorSpace()->id() != "RGBA" && pd->colorSpace()->id() != "RGBA16"))
|| (!rgb && (pd->colorSpace()->id() != "GRAYA" && pd->colorSpace()->id() != "GRAYA16")))) {
if (rgb) {
pd->convertTo(KoColorSpaceRegistry::instance()->rgb8(0));
pd->convertTo(KoColorSpaceRegistry::instance()->rgb8(0), KoColorConversionTransformation::IntentPerceptual, KoColorConversionTransformation::BlackpointCompensation);
}
else {
pd->convertTo(KoColorSpaceRegistry::instance()->colorSpace(GrayAColorModelID.id(), Integer8BitsColorDepthID.id(), 0));
pd->convertTo(KoColorSpaceRegistry::instance()->colorSpace(GrayAColorModelID.id(), Integer8BitsColorDepthID.id(), 0), KoColorConversionTransformation::IntentPerceptual, KoColorConversionTransformation::BlackpointCompensation);
}
}
......
......@@ -282,7 +282,7 @@ KisImageBuilder_Result KisTIFFConverter::readTIFFDirectory(TIFF* image)
KoColorTransformation* transform = 0;
if (profile && !profile->isSuitableForOutput()) {
dbgFile << "The profile can't be used in krita, need conversion";
transform = KoColorSpaceRegistry::instance()->colorSpace(colorSpaceId.first, colorSpaceId.second, profile)->createColorConverter(cs);
transform = KoColorSpaceRegistry::instance()->colorSpace(colorSpaceId.first, colorSpaceId.second, profile)->createColorConverter(cs, KoColorConversionTransformation::IntentPerceptual, KoColorConversionTransformation::BlackpointCompensation);
}
// Check if there is an alpha channel
......
......@@ -107,7 +107,7 @@ void KisColorSmudgeOp::updateMask(const KisPaintInformation& info, double scale,
// transforms the fixed paint device with the current brush
// to alpha color space to use it as an alpha/transparency mask
m_maskDab->convertTo(KoColorSpaceRegistry::instance()->alpha8());
m_maskDab->convertTo(KoColorSpaceRegistry::instance()->alpha8(), KoColorConversionTransformation::IntentPerceptual, KoColorConversionTransformation::BlackpointCompensation);
}
qreal KisColorSmudgeOp::paintAt(const KisPaintInformation& info)
......
......@@ -294,13 +294,13 @@ qreal KisDuplicateOp::paintAt(const KisPaintInformation& info)
KisFixedPaintDeviceSP dab = 0;
if (brush->brushType() == IMAGE || brush->brushType() == PIPE_IMAGE) {
dab = brush->paintDevice(m_srcdev->colorSpace(), scale, 0.0, info, xFraction, yFraction);
dab->convertTo(KoColorSpaceRegistry::instance()->alpha8());
dab->convertTo(KoColorSpaceRegistry::instance()->alpha8(), KoColorConversionTransformation::IntentPerceptual, KoColorConversionTransformation::BlackpointCompensation);
} else {
dab = cachedDab();
KoColor color = painter()->paintColor();
color.convertTo(dab->colorSpace());
brush->mask(dab, color, scale, scale, 0.0, info, xFraction, yFraction);
dab->convertTo(KoColorSpaceRegistry::instance()->alpha8());
dab->convertTo(KoColorSpaceRegistry::instance()->alpha8(), KoColorConversionTransformation::IntentPerceptual, KoColorConversionTransformation::BlackpointCompensation);
}
QRect dstRect = QRect(x, y, dab->bounds().width(), dab->bounds().height());
......
......@@ -125,13 +125,13 @@ qreal KisHatchingPaintOp::paintAt(const KisPaintInformation& info)
simple, ugly, hatched rectangle.*/
if (brush->brushType() == IMAGE || brush->brushType() == PIPE_IMAGE) {
maskDab = brush->paintDevice(device->colorSpace(), scale, 0.0, info, xFraction, yFraction);
maskDab->convertTo(KoColorSpaceRegistry::instance()->alpha8());
maskDab->convertTo(KoColorSpaceRegistry::instance()->alpha8(), KoColorConversionTransformation::IntentPerceptual, KoColorConversionTransformation::BlackpointCompensation);
} else {
maskDab = cachedDab();
KoColor color = painter()->paintColor();
color.convertTo(maskDab->colorSpace());
brush->mask(maskDab, color, scale, scale, 0.0, info, xFraction, yFraction);
maskDab->convertTo(KoColorSpaceRegistry::instance()->alpha8());
maskDab->convertTo(KoColorSpaceRegistry::instance()->alpha8(), KoColorConversionTransformation::IntentPerceptual, KoColorConversionTransformation::BlackpointCompensation);
}
/*-----Convenient renaming for the limits of the maskDab, this will be used
......
......@@ -575,7 +575,7 @@ KisFixedPaintDeviceSP KisBrush::paintDevice(const KoColorSpace * colorSpace,
dab2->initialize();
dabPointer = dab->data();
quint8* dabPointer2 = dab2->data();
KoColorSpaceRegistry::instance()->rgb8()->convertPixelsTo(dabPointer, dabPointer2, colorSpace, outputWidth * outputHeight);
KoColorSpaceRegistry::instance()->rgb8()->convertPixelsTo(dabPointer, dabPointer2, colorSpace, outputWidth * outputHeight, KoColorConversionTransformation::IntentPerceptual, KoColorConversionTransformation::BlackpointCompensation);
dab = dab2;
}
return dab;
......
......@@ -298,7 +298,7 @@ bool KisGbrBrush::initFromPaintDev(KisPaintDeviceSP image, int x, int y, int w,
{
// Forcefully convert to RGBA8
// XXX profile and exposure?
setImage(image->convertToQImage(0, x, y, w, h));
setImage(image->convertToQImage(0, x, y, w, h, KoColorConversionTransformation::IntentPerceptual, KoColorConversionTransformation::BlackpointCompensation));
setName(image->objectName());
setHasColor(true);
......
......@@ -88,7 +88,7 @@ bool MyPaintSurface::draw_dab (float x, float y,
//uint16_t * rgba_p = get_tile_memory(tx, ty, false);
m_dst->readBytes(m_dstData, tx * TILE_SIZE, ty * TILE_SIZE, TILE_SIZE, TILE_SIZE);
m_dst->colorSpace()->convertPixelsTo(m_dstData, m_dstRgb16Data, m_rgb16, TILE_SIZE * TILE_SIZE);
m_dst->colorSpace()->convertPixelsTo(m_dstData, m_dstRgb16Data, m_rgb16, TILE_SIZE * TILE_SIZE, KoColorConversionTransformation::IntentPerceptual, KoColorConversionTransformation::BlackpointCompensation);
quint16* rgba_p = reinterpret_cast<quint16*>(m_dstRgb16Data);
......@@ -156,7 +156,7 @@ bool MyPaintSurface::draw_dab (float x, float y,
}
}
}
m_rgb16->convertPixelsTo(m_dstRgb16Data, m_dstData, m_dst->colorSpace(), TILE_SIZE * TILE_SIZE);
m_rgb16->convertPixelsTo(m_dstRgb16Data, m_dstData, m_dst->colorSpace(), TILE_SIZE * TILE_SIZE, KoColorConversionTransformation::IntentPerceptual, KoColorConversionTransformation::BlackpointCompensation);