Commit 3b06b458 authored by Cyrille Berger's avatar Cyrille Berger

refactor KoColorProfile, free it from lcms ism

introduce KoIccColorProfile to handle icc profiile (without being tied to lcms)

svn path=/trunk/koffice/; revision=663878
parent 62ec552b
......@@ -36,7 +36,7 @@ XYZU16Plugin::XYZU16Plugin(QObject *parent, const QStringList &)
KoColorSpaceFactory * csf = new KisXyzU16ColorSpaceFactory();
f->add(csf);
KoColorProfile *xyzProfile = new KoColorProfile(cmsCreateXYZProfile());
KoColorProfile *xyzProfile = new KoLcmsColorProfile(cmsCreateXYZProfile());
f->addProfile(xyzProfile);
KoColorSpace * colorSpaceXYZU16 = new KisXyzU16ColorSpace(f, KoColorSpaceRegistry::instance()->profileByName(csf->defaultProfile()));
......
......@@ -37,7 +37,7 @@
#include "KoColorSpaceRegistry.h"
#include "KoColor.h"
#include "KoColorProfile.h"
#include "colorprofiles/KoIccColorProfile.h"
#include "kis_annotation.h"
#include "kis_types.h"
......@@ -1240,8 +1240,14 @@ vKisAnnotationSP_it KisImage::beginAnnotations()
{
// XXX we hardcode icc, this is correct for lcms?
// XXX productName(), or just "ICC Profile"?
if (!profile->rawData().isEmpty())
annotation = new KisAnnotation("icc", profile->productName(), profile->rawData());
if( profile->valid())
{
KoIccColorProfile* iccprofile = dynamic_cast<KoIccColorProfile*>(profile);
if (!iccprofile->rawData().isEmpty())
{
annotation = new KisAnnotation("icc", iccprofile->name(), iccprofile->rawData());
}
}
}
if (annotation)
......
......@@ -99,7 +99,6 @@ KisLayer::KisLayer(const KisLayer& rhs)
KisLayer::~KisLayer()
{
kDebug() << "~~~~~~~~~~ delete " << this << endl;
}
KoColorSpace * KisLayer::colorSpace()
......@@ -413,9 +412,7 @@ void KisLayer::setCompositeOpPrivate( const KoCompositeOp * op )
void KisLayer::setParentPrivate( KisGroupLayerSP parent )
{
kDebug() << "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ " << this << " " << parent.data() << endl;
m_d->parent = parent;
kDebug() << "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ " << this << " " << m_d->parent.data() << endl;
}
void KisIndirectPaintingSupport::setTemporaryTarget(KisPaintDeviceSP t) {
......
......@@ -163,7 +163,7 @@ KoDocumentSectionModel::PropertyList KisPaintLayer::properties() const
KoDocumentSectionModel::PropertyList l = super::properties();
l << KoDocumentSectionModel::Property(i18n("Colorspace"), paintDevice()->colorSpace()->name());
if( KoColorProfile *profile = paintDevice()->colorSpace()->profile() )
l << KoDocumentSectionModel::Property(i18n("Profile"), profile->productName());
l << KoDocumentSectionModel::Property(i18n("Profile"), profile->name());
return l;
}
......
......@@ -91,7 +91,7 @@ void DlgColorSpaceConversion::fillCmbDestProfile(const KoID & s)
QList<KoColorProfile *> profileList = KoColorSpaceRegistry::instance()->profilesFor(s);
foreach (KoColorProfile *profile, profileList) {
m_page->cmbDestProfile->addSqueezedItem(profile->productName());
m_page->cmbDestProfile->addSqueezedItem(profile->name());
}
}
......
......@@ -29,7 +29,7 @@
#include <KoZoomHandler.h>
#include <KoViewConverter.h>
#include <KoShapeManager.h>
#include <KoColorProfile.h>
#include <colorprofiles/KoIccColorProfile.h>
#include <KoColorSpaceRegistry.h>
#include <KoCanvasController.h>
#include <KoDocument.h>
......@@ -321,7 +321,7 @@ KoColorProfile * KisCanvas2::monitorProfile()
void KisCanvas2::resetMonitorProfile()
{
// XXX: The X11 monitor profile overrides the settings
m_d->monitorProfile = KoColorProfile::getScreenProfile();
m_d->monitorProfile = KoIccColorProfile::getScreenProfile();
if (m_d->monitorProfile == 0) {
KisConfig cfg;
......
......@@ -31,7 +31,7 @@
#include "KoStore.h"
#include "KoStoreDrag.h"
#include <KoColorSpaceRegistry.h>
#include <KoColorProfile.h>
#include <colorprofiles/KoIccColorProfile.h>
// kritaimage
#include <kis_types.h>
......@@ -114,10 +114,9 @@ void KisClipboard::setClip(KisPaintDeviceSP selection)
KisAnnotationSP annotation;
if (profile)
{
// XXX we hardcode icc, this is correct for lcms?
// XXX productName(), or just "ICC Profile"?
if (!profile->rawData().isEmpty())
annotation = new KisAnnotation("icc", profile->productName(), profile->rawData());
KoIccColorProfile* iccprofile = dynamic_cast<KoIccColorProfile*>(profile);
if (iccprofile and !iccprofile->rawData().isEmpty())
annotation = new KisAnnotation("icc", iccprofile->name(), iccprofile->rawData());
}
if (annotation) {
// save layer profile
......@@ -171,7 +170,7 @@ KisPaintDeviceSP KisClipboard::clip()
store->open("profile.icc");
data = store->read(store->size());
store->close();
profile = new KoColorProfile(data);
profile = new KoIccColorProfile(data);
}
QString csName;
......@@ -269,7 +268,7 @@ QSize KisClipboard::clipSize()
store->open("profile.icc");
data = store->read(store->size());
store->close();
profile = new KoColorProfile(data);
profile = new KoIccColorProfile(data);
}
QString csName;
......
......@@ -197,7 +197,7 @@ void KisCustomImageWidget::fillCmbProfiles(const KoID & s)
QList<KoColorProfile *> profileList = KoColorSpaceRegistry::instance()->profilesFor( csf );
foreach (KoColorProfile *profile, profileList) {
cmbProfile->addSqueezedItem(profile->productName());
cmbProfile->addSqueezedItem(profile->name());
}
cmbProfile->setCurrent(csf->defaultProfile());
}
......
......@@ -104,7 +104,7 @@ void KisDlgApplyProfile::fillCmbProfiles(const KoID & s)
QList<KoColorProfile *> profileList = KoColorSpaceRegistry::instance()->profilesFor( csf );
foreach (KoColorProfile *profile, profileList) {
m_page->cmbProfile->addSqueezedItem(profile->productName());
m_page->cmbProfile->addSqueezedItem(profile->name());
}
m_page->cmbProfile->setCurrent(csf->defaultProfile());
}
......
......@@ -82,7 +82,7 @@ KisDlgImageProperties::KisDlgImageProperties(KisImageSP image, QWidget *parent,
fillCmbProfiles(KoID(image->colorSpace()->id()));
if (image->profile()) {
m_page->cmbProfile->setCurrent(image->profile()->productName());
m_page->cmbProfile->setCurrent(image->profile()->name());
}
else {
m_page->cmbProfile->setCurrentIndex(0);
......@@ -165,7 +165,7 @@ void KisDlgImageProperties::fillCmbProfiles(const KoID & s)
QList<KoColorProfile *> profileList = KoColorSpaceRegistry::instance()->profilesFor( csf );
foreach (KoColorProfile *profile, profileList) {
m_page->cmbProfile->addSqueezedItem(profile->productName());
m_page->cmbProfile->addSqueezedItem(profile->name());
}
}
}
......
......@@ -74,7 +74,7 @@ KisDlgLayerProperties::KisDlgLayerProperties(const QString& deviceName,
QString profilename;
if (KoColorProfile* profile = const_cast<KoColorSpace *>(colorSpace)->profile())
profilename = profile->productName();
profilename = profile->name();
m_page->cmbProfile->addSqueezedItem(profilename);
m_page->cmbProfile->setEnabled(false);
......
......@@ -105,7 +105,7 @@ void NewLayerDialog::fillCmbProfiles(const KoID & s)
QList<KoColorProfile *> profileList = KoColorSpaceRegistry::instance()->profilesFor( csf );
foreach (KoColorProfile *profile, profileList) {
m_page->cmbProfile->addSqueezedItem(profile->productName());
m_page->cmbProfile->addSqueezedItem(profile->name());
}
m_page->cmbProfile->setCurrent(csf->defaultProfile());
}
......
......@@ -38,7 +38,7 @@
#endif
#include <KoImageResource.h>
#include <KoColorProfile.h>
#include <colorprofiles/KoIccColorProfile.h>
#include <kcolorbutton.h>
#include <kcombobox.h>
......@@ -167,10 +167,10 @@ ColorSettingsTab::ColorSettingsTab(QWidget *parent, const char *name )
m_page->cmbMonitorIntent->setCurrentIndex(cfg.renderIntent());
if ( KoColorProfile * profile = KoColorProfile::getScreenProfile() ) {
if ( KoIccColorProfile * profile = KoIccColorProfile::getScreenProfile() ) {
// We've got an X11 profile, don't allow to override
m_page->cmbMonitorProfile->hide();
m_page->lblMonitorProfile->setText( i18n( "Monitor profile: " ) + profile->productName() );
m_page->lblMonitorProfile->setText( i18n( "Monitor profile: " ) + profile->name() );
}
else {
m_page->cmbMonitorProfile->show();
......@@ -212,8 +212,8 @@ void ColorSettingsTab::refillMonitorProfiles(const KoID & s)
QList<KoColorProfile *> profileList = KoColorSpaceRegistry::instance()->profilesFor( csf );
foreach (KoColorProfile *profile, profileList) {
if (profile->deviceClass() == icSigDisplayClass)
m_page->cmbMonitorProfile->addSqueezedItem(profile->productName());
if (profile->isSuitableForDisplay())
m_page->cmbMonitorProfile->addSqueezedItem(profile->name());
}
m_page->cmbMonitorProfile->setCurrent(csf->defaultProfile());
......@@ -231,8 +231,8 @@ void ColorSettingsTab::refillPrintProfiles(const KoID & s)
QList<KoColorProfile *> profileList = KoColorSpaceRegistry::instance()->profilesFor( csf );
foreach (KoColorProfile *profile, profileList) {
if (profile->deviceClass() == icSigOutputClass)
m_page->cmbPrintProfile->addSqueezedItem(profile->productName());
if (profile->isSuitableForPrinting() )
m_page->cmbPrintProfile->addSqueezedItem(profile->name());
}
m_page->cmbPrintProfile->setCurrent(csf->defaultProfile());
......
......@@ -45,7 +45,7 @@
// KOffice
#include <KoApplication.h>
#include <KoCanvasBase.h>
#include <KoColorProfile.h>
#include <colorprofiles/KoIccColorProfile.h>
#include <KoColorSpace.h>
#include <KoColorSpaceRegistry.h>
#include <KoFilterManager.h>
......@@ -343,7 +343,7 @@ QDomElement KisDoc2::saveImage(QDomDocument& doc, KisImageSP img)
image.setAttribute("description", img->description());
// XXX: Save profile as blob inside the image, instead of the product name.
if (img->profile() && img->profile()-> valid())
image.setAttribute("profile", img->profile()->productName());
image.setAttribute("profile", img->profile()->name());
image.setAttribute("x-res", img->xRes());
image.setAttribute("y-res", img->yRes());
......@@ -691,10 +691,9 @@ bool KisDoc2::completeSaving(KoStore *store)
KisAnnotationSP annotation;
if (profile)
{
// XXX we hardcode icc, this is correct for lcms?
// XXX productName(), or just "ICC Profile"?
if (!profile->rawData().isEmpty())
annotation = new KisAnnotation("icc", profile->productName(), profile->rawData());
KoIccColorProfile* iccprofile = dynamic_cast<KoIccColorProfile*>(profile);
if (iccprofile and !iccprofile->rawData().isEmpty())
annotation = new KisAnnotation("icc", iccprofile->name(), iccprofile->rawData());
}
if (annotation) {
......@@ -750,7 +749,7 @@ bool KisDoc2::completeLoading(KoStore *store)
store->open(location);
data = store->read(store->size());
store->close();
img->setProfile(new KoColorProfile(data));
img->setProfile(new KoIccColorProfile(data));
}
IODone();
......
......@@ -448,7 +448,7 @@ void KisLayerManager::addLayer(KisGroupLayerSP parent, KisLayerSP above)
KisConfig cfg;
QString profilename;
if(img->colorSpace()->profile())
profilename = img->colorSpace()->profile()->productName();
profilename = img->colorSpace()->profile()->name();
NewLayerDialog dlg(KoID(img->colorSpace()->id()), profilename, img->nextLayerName(), m_view);
if (dlg.exec() == QDialog::Accepted) {
......@@ -474,7 +474,7 @@ void KisLayerManager::addGroupLayer(KisGroupLayerSP parent, KisLayerSP above)
if (img) {
QString profilename;
if(img->colorSpace()->profile())
profilename = img->colorSpace()->profile()->productName();
profilename = img->colorSpace()->profile()->name();
KisConfig cfg;
NewLayerDialog dlg(KoID(img->colorSpace()->id()), profilename, img->nextLayerName(), m_view);
dlg.setColorSpaceEnabled(false);
......
/*
* Copyright (c) 2007 Boudewijn Rempt <boud@valdyas.org>
* Copyright (c) 2007 Cyrille Berger <cberger@cberger.net>
*
* this program is free software; you can redistribute it and/or modify
* it under the terms of the gnu general public license as published by
......@@ -267,6 +268,13 @@ void KisLayerModel::endRemoveLayers( KisGroupLayer *, int )
endRemoveRows();
}
QMimeData * KisLayerModel::mimeData ( const QModelIndexList & indexes ) const
{
kDebug(41007) << "KisLayerModel::mimeData" << endl;
QMimeData* data = new QMimeData;
}
bool KisLayerModel::dropMimeData ( const QMimeData * data, Qt::DropAction action, int row, int column, const QModelIndex & parent )
{
kDebug(41007) << "KisLayerModel::dropMimeData" << endl;
......
......@@ -52,6 +52,7 @@ public: // from QAbstractItemModel
virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
virtual Qt::ItemFlags flags(const QModelIndex &index) const;
virtual bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole);
QMimeData * mimeData ( const QModelIndexList & indexes ) const;
virtual bool dropMimeData ( const QMimeData * data, Qt::DropAction action, int row, int column, const QModelIndex & parent );
virtual Qt::DropActions supportedDragActions () const;
......
......@@ -22,7 +22,7 @@
#include <QRect>
#include <KoColorSpaceRegistry.h>
#include <KoColorProfile.h>
#include <colorprofiles/KoIccColorProfile.h>
#include <KoStore.h>
// kritaimage
......@@ -85,7 +85,7 @@ bool KisLoadVisitor::visit(KisPaintLayer *layer)
data = m_store->read(m_store->size());
m_store->close();
// Create a colorspace with the embedded profile
KoColorSpace * cs = KoColorSpaceRegistry::instance()->colorSpace(layer->paintDevice()->colorSpace()->id(), new KoColorProfile(data));
KoColorSpace * cs = KoColorSpaceRegistry::instance()->colorSpace(layer->paintDevice()->colorSpace()->id(), new KoIccColorProfile(data));
// replace the old colorspace
layer->paintDevice()->setData(layer->paintDevice()->dataManager(), cs);
QRect rc = layer->paintDevice()->extent();
......
......@@ -36,13 +36,13 @@
#include <KoDocumentInfo.h>
#include <KoID.h>
#include <KoColorSpaceRegistry.h>
#include <colorprofiles/KoIccColorProfile.h>
#include <kis_doc2.h>
#include <kis_image.h>
#include <kis_iterators_pixel.h>
#include <kis_layer.h>
#include <kis_meta_registry.h>
#include <KoColorProfile.h>
#include <kis_paint_layer.h>
#include <kis_group_layer.h>
......@@ -280,10 +280,10 @@ KisImageBuilder_Result KisPNGConverter::buildImage(QIODevice* iod)
if (QString::compare(profile_name, "icc") == 0) {
profile_rawdata.resize(proflen);
memcpy(profile_rawdata.data(), profile_data, proflen);
profile = new KoColorProfile(profile_rawdata);
profile = new KoIccColorProfile(profile_rawdata);
Q_CHECK_PTR(profile);
if (profile) {
kDebug(41008) << "profile name: " << profile->productName() << " profile description: " << profile->productDescription() << " information sur le produit: " << profile->productInfo() << endl;
// kDebug(41008) << "profile name: " << profile->productName() << " profile description: " << profile->productDescription() << " information sur le produit: " << profile->productInfo() << endl;
if(!profile->isSuitableForOutput())
{
kDebug(41008) << "the profile is not suitable for output and therefore cannot be used in krita, we need to convert the image to a standard profile" << endl; // TODO: in ko2 popup a selection menu to inform the user
......@@ -296,7 +296,7 @@ KisImageBuilder_Result KisPNGConverter::buildImage(QIODevice* iod)
KoColorSpace* cs;
if (profile && profile->isSuitableForOutput())
{
kDebug(41008) << "image has embedded profile: " << profile -> productName() << "\n";
kDebug(41008) << "image has embedded profile: " << profile -> name() << "\n";
cs = KoColorSpaceRegistry::instance()->colorSpace(csName, profile);
}
else
......@@ -383,8 +383,9 @@ KisImageBuilder_Result KisPNGConverter::buildImage(QIODevice* iod)
KisAnnotationSP annotation;
// XXX we hardcode icc, this is correct for lcms?
// XXX productName(), or just "ICC Profile"?
if (!profile->rawData().isEmpty())
annotation = new KisAnnotation("icc", profile->productName(), profile->rawData());
KoIccColorProfile* iccprofile = dynamic_cast<KoIccColorProfile*>(profile);
if ( iccprofile and !iccprofile->rawData().isEmpty())
annotation = new KisAnnotation("icc", iccprofile->name(), iccprofile->rawData());
m_img -> addAnnotation( annotation );
}
}
......
......@@ -19,7 +19,7 @@
#include <kis_save_visitor.h>
#include <KoColorProfile.h>
#include <colorprofiles/KoIccColorProfile.h>
#include <KoStore.h>
#include "kis_adjustment_layer.h"
......@@ -75,10 +75,9 @@ bool KisSaveVisitor::visit(KisPaintLayer *layer)
KisAnnotationSP annotation;
if (profile)
{
// XXX we hardcode icc, this is correct for lcms?
// XXX productName(), or just "ICC Profile"?
if (!profile->rawData().isEmpty())
annotation = new KisAnnotation("icc", profile->productName(), profile->rawData());
KoIccColorProfile* iccprofile = dynamic_cast<KoIccColorProfile*>(profile);
if (iccprofile and !iccprofile->rawData().isEmpty())
annotation = new KisAnnotation("icc", iccprofile->name(), iccprofile->rawData());
}
if (annotation) {
......
......@@ -135,7 +135,7 @@ void KisStatusBar::setProfile( KisImageSP img )
m_statusBarProfileLabel->setText(i18n("No profile"));
}
else {
m_statusBarProfileLabel->setText(img->colorSpace()->name() + " " + img->profile()->productName());
m_statusBarProfileLabel->setText(img->colorSpace()->name() + " " + img->profile()->name());
}
}
......
......@@ -19,6 +19,8 @@ set(pigment_SRCS
KoBasicHistogramProducers.cpp
KoHistogramProducer.cpp
# ${FILE_OPENEXR_SOURCES}
${CMAKE_CURRENT_SOURCE_DIR}/colorprofiles/KoIccColorProfile.cpp
${CMAKE_CURRENT_SOURCE_DIR}/colorprofiles/KoLcmsColorProfile.cpp
${CMAKE_CURRENT_SOURCE_DIR}/colorspaces/KoAlphaColorSpace.cpp
${CMAKE_CURRENT_SOURCE_DIR}/colorspaces/KoLabColorSpace.cpp
${CMAKE_CURRENT_SOURCE_DIR}/colorspaces/KoRgbU16ColorSpace.cpp
......
......@@ -29,8 +29,7 @@
// #include "Ko_global.h"
#include "KoIntegerMaths.h"
#include "KoChannelInfo.h"
#include "KoColorSpace.h"
#include "colorspaces/KoLabColorSpace.h"
#include "KoLcmsColorSpace.h"
// TODO: get ride of this
const quint8 quint8_MAX = UCHAR_MAX;
......@@ -40,7 +39,7 @@ const qint32 qint32_MAX = (2147483647);
const qint32 qint32_MIN = (-2147483647-1);
KoLabColorSpace* KoGenericLabHistogramProducer::m_labCs = 0;
KoColorSpace* KoGenericLabHistogramProducer::m_labCs = 0;
KoBasicHistogramProducer::KoBasicHistogramProducer(const KoID& id, int channels, int nrOfBins, KoColorSpace *cs)
......@@ -420,8 +419,7 @@ KoGenericLabHistogramProducer::KoGenericLabHistogramProducer()
m_channelsList.append(new KoChannelInfo(i18n("b*"), 2, KoChannelInfo::COLOR, KoChannelInfo::UINT8));
if (!m_labCs) {
KoColorProfile *labProfile = new KoColorProfile(cmsCreateLabProfile(NULL));
m_labCs = new KoLabColorSpace(0, labProfile);
m_labCs = KoColorSpaceRegistry::instance()->lab16();
}
m_colorSpace = m_labCs;
}
......
......@@ -30,8 +30,6 @@
#include "KoID.h"
#include <pigment_export.h>
class KoLabColorSpace;
class PIGMENT_EXPORT KoBasicHistogramProducer : public KoHistogramProducer {
public:
KoBasicHistogramProducer(const KoID& id, int channels, int nrOfBins, KoColorSpace *colorSpace);
......@@ -182,7 +180,7 @@ class PIGMENT_EXPORT KoGenericLabHistogramProducer : public KoBasicHistogramPro
protected:
QList<KoChannelInfo *> m_channelsList;
private:
static KoLabColorSpace* m_labCs;
static KoColorSpace* m_labCs;
};
/** KoGenericLabHistogramProducer his special Factory that isCompatibleWith everything. */
......
/*
* This file is part of the KDE project
* Copyright (c) 2000 Matthias Elter <elter@kde.org>
* 2001 John Califf
* 2004 Boudewijn Rempt <boud@valdyas.org>
* Copyright (C) 2007 Thomas Zander <zander@kde.org>
* Copyright (c) 2007 Cyrille Berger <cberger@cberger.net>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Library General Public License
* You should have received a copy of the GNU Lesser General Public License
* along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#include <cfloat>
#include <cmath>
#include <lcms.h>
#include <limits.h>
#include <QImage>
#include <QFile>
#include <kdebug.h>
#include "KoColorProfile.h"
#include <kdebug.h>
#ifdef Q_WS_X11
#include <X11/Xlib.h>
#include <X11/Xatom.h>
#include <fixx11h.h>
#include <QX11Info>
#endif
class KoColorProfile::Private {
public:
Private() : valid(false), suitableForOutput(false) { }
cmsHPROFILE profile;
icColorSpaceSignature colorSpaceSignature;
icProfileClassSignature deviceClass;
QString productName;
QString productDescription;
QString productInfo;
QString manufacturer;
QByteArray rawData;
QString filename;
bool valid;
bool suitableForOutput;
};
KoColorProfile::KoColorProfile(const QByteArray& rawData)
: d(new Private())
{
d->rawData = rawData;
d->profile = cmsOpenProfileFromMem((void*)rawData.constData(), (DWORD)rawData.size());
init();
}
KoColorProfile::KoColorProfile(const QString& file)
: d(new Private())
struct KoColorProfile::Private
{
d->filename = file;
}
QString name;
QString info;
QString fileName;
};
KoColorProfile::KoColorProfile(const cmsHPROFILE profile)
: d(new Private())
KoColorProfile::KoColorProfile(QString fileName) : d(new Private)
{
d->profile = profile;
d->valid = true;
size_t bytesNeeded=0;
// Make a raw data image ready for saving
_cmsSaveProfileToMem(d->profile, 0, &bytesNeeded); // calc size
d->rawData.resize(bytesNeeded);
if(d->rawData.size() >= (int)bytesNeeded)
{
_cmsSaveProfileToMem(d->profile, d->rawData.data(), &bytesNeeded); // fill buffer
cmsHPROFILE newprofile = cmsOpenProfileFromMem((void*)d->rawData.constData(), (DWORD) bytesNeeded);
cmsCloseProfile(d->profile);
d->profile = newprofile;
}
else
d->rawData.resize(0);
init();
// kDebug() << " Profile filename = " << fileName << endl;
d->fileName = fileName;
}
KoColorProfile::~KoColorProfile()
{
cmsCloseProfile(d->profile);
delete d;
}
bool KoColorProfile::load()
{
QFile file(d->filename);
file.open(QIODevice::ReadOnly);
d->rawData = file.readAll();
d->profile = cmsOpenProfileFromMem((void*)d->rawData.constData(), (DWORD)d->rawData.size());
file.close();
if (d->profile == 0) {
kWarning() << "Failed to load profile from " << d->filename << endl;
}
{ return false; }
return init();
bool KoColorProfile::save(QString /*fileName*/)
{ return false; }
}
bool KoColorProfile::init()
QString KoColorProfile::name() const
{
if (d->profile) {
d->colorSpaceSignature = cmsGetColorSpace(d->profile);
d->deviceClass = cmsGetDeviceClass(d->profile);
d->productName = cmsTakeProductName(d->profile);
d->productDescription = cmsTakeProductDesc(d->profile);
d->productInfo = cmsTakeProductInfo(d->profile);
d->valid = true;
// Check if the profile can convert (something->this)
// LPMATSHAPER OutMatShaper = cmsBuildOutputMatrixShaper(d->profile);
// if( OutMatShaper )
// {
// d->suitableForOutput = true;
// }
cmsCIEXYZTRIPLE Primaries;
if (cmsTakeColorants(&Primaries, d->profile))
{
d->suitableForOutput = true;
}
#if 0
// XXX: It wasn't that easy to save a little memory: thsi gives an lcms error
// Okay, we know enough. Free the memory; we'll load it again if needed.
cmsCloseProfile(d->profile);
d->profile = 0;
#endif
return true;
}
return false;
return d->name;
}
cmsHPROFILE KoColorProfile::profile()
QString KoColorProfile::info() const
{
#if 0
if (d->profile = 0) {
QFile file(d->filename);
file.open(QIODevice::ReadOnly);
d->rawData = file.readAll();
d->profile = cmsOpenProfileFromMem((void*)d->rawData.constData(), (DWORD)d->rawData.size());
file.close();
}
#endif
return d->profile;
return d->info;
}
bool KoColorProfile::save()