r14179 by jghali - - make lcms error handling purely internal to ScLcmsColorMngtEngineImpl using an exception based mechanism - remove use of util_cms.h and cmserrorhandling.h includes
scribus-commit
scribus-commit at lists.scribus.net
Sun Oct 18 21:35:36 CEST 2009
Revision: 14179
Author: jghali
Date: 2009-10-18T17:11:27.304168Z
Commit message: - make lcms error handling purely internal to ScLcmsColorMngtEngineImpl using an exception based mechanism
- remove use of util_cms.h and cmserrorhandling.h includes
Changeset:
M /trunk/Scribus/scribus/scimage.cpp
M /trunk/Scribus/scribus/colormngt/sccolorprofile.cpp
M /trunk/Scribus/scribus/pslib.cpp
M /trunk/Scribus/scribus/colormngt/sclcmscolormngtengineimpl.h
M /trunk/Scribus/scribus/scdocoutput_ps2.cpp
M /trunk/Scribus/scribus/scribusdoc.cpp
M /trunk/Scribus/scribus/scribuscore.cpp
M /trunk/Scribus/scribus/colormngt/sclcmscolormngtengineimpl.cpp
Diffs:
Index: scribus/scribuscore.cpp
===================================================================
--- scribus/scribuscore.cpp (revision 14178)
+++ scribus/scribuscore.cpp (revision 14179)
@@ -25,7 +25,6 @@
#include <QDebug>
#include <QGlobalStatic>
-#include "cmserrorhandling.h"
#include "commonstrings.h"
#include "filewatcher.h"
#include "pluginmanager.h"
@@ -37,15 +36,11 @@
#include "undomanager.h"
#include "util.h"
#include "util_icon.h"
-#include "util_cms.h"
#include "util_ghostscript.h"
#include "colormngt/sccolormngtenginefactory.h"
-
extern ScribusQApp* ScQApp;
-#include "cmserrorhandling.h"
-
ScribusCore::ScribusCore() : QObject(), defaultEngine(colorMngtEngineFactory.createDefaultEngine())
{
m_ScribusInitialized=false;
@@ -449,19 +444,6 @@
void ScribusCore::InitDefaultColorTransforms(void)
{
- cmsErrorAction(LCMS_ERROR_ABORT);
- if (setjmp(cmsJumpBuffer))
- {
- // Reset to the default handler otherwise may enter a loop
- // if an error occur afterwards
- cmsSetErrorHandler(NULL);
- cmsErrorAction(LCMS_ERROR_IGNORE);
- ResetDefaultColorTransforms();
- cmsErrorAction(LCMS_ERROR_ABORT);
- return;
- }
- cmsSetErrorHandler(&cmsErrorHandler);
-
// Ouvre le profile RGB par d�fault
if (InputProfiles.contains("sRGB IEC61966-2.1"))
defaultRGBProfile = defaultEngine.openProfileFromFile(InputProfiles["sRGB IEC61966-2.1"]);
@@ -477,7 +459,6 @@
if (!defaultRGBProfile || !defaultCMYKProfile)
{
ResetDefaultColorTransforms();
- cmsSetErrorHandler(NULL);
return;
}
@@ -500,7 +481,6 @@
{
ResetDefaultColorTransforms();
}
- cmsSetErrorHandler(NULL);
}
void ScribusCore::ResetDefaultColorTransforms(void)
Index: scribus/colormngt/sclcmscolormngtengineimpl.cpp
===================================================================
--- scribus/colormngt/sclcmscolormngtengineimpl.cpp (revision 14178)
+++ scribus/colormngt/sclcmscolormngtengineimpl.cpp (revision 14179)
@@ -6,6 +6,7 @@
*/
#include <iostream>
+#include <string>
#include <QDir>
#include <QFile>
@@ -17,8 +18,6 @@
#define cmsFLAGS_PRESERVEBLACK 0x8000
#endif
-jmp_buf ScLcmsColorMngtEngineImpl::cmsJumpBuffer;
-
QSharedPointer<ScColorProfileCache> ScLcmsColorMngtEngineImpl::m_profileCache;
ScLcmsColorMngtEngineImpl::ScLcmsColorMngtEngineImpl()
@@ -76,39 +75,39 @@
if (len == 40 && bb[36] == 'a' && bb[37] == 'c' && bb[38] == 's' && bb[39] == 'p')
{
const QByteArray profilePath( QString(directory + "/" + file).toLocal8Bit() );
- if (setjmp(cmsJumpBuffer))
+ cmsSetErrorHandler(&cmsErrorHandler);
+ try
{
+ hIn = cmsOpenProfileFromFile(profilePath.data(), "r");
+ if (hIn == NULL)
+ continue;
+ const char* profileDescriptor = cmsTakeProductDesc(hIn);
+ profileInfo.description = QString(profileDescriptor);
+ if (profileInfo.description.isEmpty())
+ {
+ cmsCloseProfile(hIn);
+ profileInfo.debug = QString("Color profile %1 is broken : no valid description").arg(fi.filePath());
+ profileInfos.append(profileInfo);
+ continue;
+ }
+ profileInfo.colorSpace = cmsGetColorSpace(hIn);
+ profileInfo.deviceClass = cmsGetDeviceClass(hIn);
+ profileInfos.append(profileInfo);
+ cmsCloseProfile(hIn);
+ hIn = NULL;
+ }
+ catch (lcmsException&)
+ {
// Profile is broken
- profileInfo.debug = QString("Color profile %1 is broken").arg(fi.filePath());
- profileInfos.append(profileInfo);
- // Reset to the default handler otherwise may enter a loop
- // if an error occur in cmsCloseProfile()
- cmsSetErrorHandler(NULL);
if (hIn)
{
cmsCloseProfile(hIn);
hIn = NULL;
}
- continue;
- }
- cmsSetErrorHandler(&cmsErrorHandler);
- hIn = cmsOpenProfileFromFile(profilePath.data(), "r");
- if (hIn == NULL)
- continue;
- const char* profileDescriptor = cmsTakeProductDesc(hIn);
- profileInfo.description = QString(profileDescriptor);
- if (profileInfo.description.isEmpty())
- {
- cmsCloseProfile(hIn);
- profileInfo.debug = QString("Color profile %1 is broken : no valid description").arg(fi.filePath());
+ profileInfo.debug = QString("Color profile %1 is broken").arg(fi.filePath());
profileInfos.append(profileInfo);
- continue;
}
- profileInfo.colorSpace = cmsGetColorSpace(hIn);
- profileInfo.deviceClass = cmsGetDeviceClass(hIn);
- profileInfos.append(profileInfo);
- cmsCloseProfile(hIn);
- hIn = NULL;
+ cmsSetErrorHandler(NULL);
}
}
cmsSetErrorHandler(NULL);
@@ -120,75 +119,139 @@
{
// Search profile in profile cache first
ScColorProfile profile;
- // We do not use lcms cmsOpenProfileFromFile() to avoid limitations
- // of I/O on 8bit filenames on Windows
- QFile file(filePath);
- if (file.open(QFile::ReadOnly))
+ cmsHPROFILE lcmsProf = NULL;
+ cmsSetErrorHandler(&cmsErrorHandler);
+ try
{
- QByteArray data = file.readAll();
- if (!data.isEmpty())
+ QFile file(filePath);
+ if (file.open(QFile::ReadOnly))
{
- cmsHPROFILE lcmsProf = cmsOpenProfileFromMem(data.data(), data.size());
- if (lcmsProf)
+ // We do not use lcms cmsOpenProfileFromFile() to avoid limitations
+ // of I/O on 8bit filenames on Windows
+ QByteArray data = file.readAll();
+ if (!data.isEmpty())
{
- ScLcmsColorProfileImpl* profData = new ScLcmsColorProfileImpl(engine, lcmsProf);
- profData->m_profileData = data;
- profData->m_profilePath = filePath;
- profile = ScColorProfile(dynamic_cast<ScColorProfileData*>(profData));
+ lcmsProf = cmsOpenProfileFromMem(data.data(), data.size());
+ if (lcmsProf)
+ {
+ ScLcmsColorProfileImpl* profData = new ScLcmsColorProfileImpl(engine, lcmsProf);
+ profData->m_profileData = data;
+ profData->m_profilePath = filePath;
+ profile = ScColorProfile(dynamic_cast<ScColorProfileData*>(profData));
+ }
+ if (profile.isNull() && lcmsProf)
+ {
+ cmsCloseProfile(lcmsProf);
+ lcmsProf = NULL;
+ }
}
- if (profile.isNull() && lcmsProf)
- cmsCloseProfile(lcmsProf);
+ file.close();
}
- file.close();
}
+ catch (lcmsException& e)
+ {
+ std::cerr << e.what() << std::endl;
+ if (profile.isNull() && lcmsProf)
+ cmsCloseProfile(lcmsProf);
+ profile = ScColorProfile();
+ }
+ cmsSetErrorHandler(NULL);
return profile;
}
ScColorProfile ScLcmsColorMngtEngineImpl::openProfileFromMem(ScColorMngtEngine& engine, const QByteArray& data)
{
ScColorProfile profile;
- cmsHPROFILE lcmsProf = cmsOpenProfileFromMem((LPVOID) data.data(), data.size());
- if (lcmsProf)
+ cmsHPROFILE lcmsProf = NULL;
+ cmsSetErrorHandler(&cmsErrorHandler);
+ try
{
- ScLcmsColorProfileImpl* profData = new ScLcmsColorProfileImpl(engine, lcmsProf);
- QString desc = profData->productDescription();
- if (!desc.isEmpty())
- profData->m_profilePath = QString("memprofile://%1").arg(desc);
- profData->m_profileData = data;
- profile = ScColorProfile(dynamic_cast<ScColorProfileData*>(profData));
+ lcmsProf = cmsOpenProfileFromMem((LPVOID) data.data(), data.size());
+ if (lcmsProf)
+ {
+ ScLcmsColorProfileImpl* profData = new ScLcmsColorProfileImpl(engine, lcmsProf);
+ QString desc = profData->productDescription();
+ if (!desc.isEmpty())
+ profData->m_profilePath = QString("memprofile://%1").arg(desc);
+ profData->m_profileData = data;
+ profile = ScColorProfile(dynamic_cast<ScColorProfileData*>(profData));
+ }
+ if (profile.isNull() && lcmsProf)
+ {
+ cmsCloseProfile(lcmsProf);
+ lcmsProf = NULL;
+ }
}
- if (profile.isNull() && lcmsProf)
- cmsCloseProfile(lcmsProf);
+ catch (lcmsException& e)
+ {
+ std::cerr << e.what() << std::endl;
+ if (profile.isNull() && lcmsProf)
+ cmsCloseProfile(lcmsProf);
+ profile = ScColorProfile();
+ }
+ cmsSetErrorHandler(NULL);
return profile;
}
ScColorProfile ScLcmsColorMngtEngineImpl::createProfile_sRGB(ScColorMngtEngine& engine)
{
ScColorProfile profile;
- cmsHPROFILE lcmsProf = cmsCreate_sRGBProfile();
- if (lcmsProf)
+ cmsHPROFILE lcmsProf = NULL;
+ cmsSetErrorHandler(&cmsErrorHandler);
+ try
{
- ScLcmsColorProfileImpl* profData = new ScLcmsColorProfileImpl(engine, lcmsProf);
- profData->m_profilePath = QString("memprofile://Internal sRGB profile");
- profile = ScColorProfile(dynamic_cast<ScColorProfileData*>(profData));
+ lcmsProf = cmsCreate_sRGBProfile();
+ if (lcmsProf)
+ {
+ ScLcmsColorProfileImpl* profData = new ScLcmsColorProfileImpl(engine, lcmsProf);
+ profData->m_profilePath = QString("memprofile://Internal sRGB profile");
+ profile = ScColorProfile(dynamic_cast<ScColorProfileData*>(profData));
+ }
+ if (profile.isNull() && lcmsProf)
+ {
+ cmsCloseProfile(lcmsProf);
+ lcmsProf = NULL;
+ }
}
- if (profile.isNull() && lcmsProf)
- cmsCloseProfile(lcmsProf);
+ catch (lcmsException& e)
+ {
+ std::cerr << e.what() << std::endl;
+ if (profile.isNull() && lcmsProf)
+ cmsCloseProfile(lcmsProf);
+ profile = ScColorProfile();
+ }
+ cmsSetErrorHandler(NULL);
return profile;
}
ScColorProfile ScLcmsColorMngtEngineImpl::createProfile_Lab(ScColorMngtEngine& engine)
{
ScColorProfile profile;
- cmsHPROFILE lcmsProf = cmsCreateLabProfile(NULL);
- if (lcmsProf)
+ cmsHPROFILE lcmsProf = NULL;
+ cmsSetErrorHandler(&cmsErrorHandler);
+ try
{
- ScLcmsColorProfileImpl* profData = new ScLcmsColorProfileImpl(engine, lcmsProf);
- profData->m_profilePath = QString("memprofile://Internal Lab profile");
- profile = ScColorProfile(dynamic_cast<ScColorProfileData*>(profData));
+ lcmsProf = cmsCreateLabProfile(NULL);
+ if (lcmsProf)
+ {
+ ScLcmsColorProfileImpl* profData = new ScLcmsColorProfileImpl(engine, lcmsProf);
+ profData->m_profilePath = QString("memprofile://Internal Lab profile");
+ profile = ScColorProfile(dynamic_cast<ScColorProfileData*>(profData));
+ }
+ if (profile.isNull() && lcmsProf)
+ {
+ cmsCloseProfile(lcmsProf);
+ lcmsProf = NULL;
+ }
}
- if (profile.isNull() && lcmsProf)
- cmsCloseProfile(lcmsProf);
+ catch (lcmsException& e)
+ {
+ std::cerr << e.what() << std::endl;
+ if (profile.isNull() && lcmsProf)
+ cmsCloseProfile(lcmsProf);
+ profile = ScColorProfile();
+ }
+ cmsSetErrorHandler(NULL);
return profile;
}
@@ -247,15 +310,28 @@
int lcmsIntent = translateIntentToLcmsIntent(renderIntent);
if (nullTransform)
lcmsFlags |= cmsFLAGS_NULLTRANSFORM;
- cmsHTRANSFORM hTransform = cmsCreateTransform(lcmsInputProf->m_profileHandle , lcmsInputFmt,
- lcmsOutputProf->m_profileHandle, lcmsOutputFmt,
- lcmsIntent, lcmsFlags | cmsFLAGS_LOWRESPRECALC);
- if (hTransform)
+ cmsHTRANSFORM hTransform = NULL;
+ cmsSetErrorHandler(&cmsErrorHandler);
+ try
{
- ScLcmsColorTransformImpl* newTrans = new ScLcmsColorTransformImpl(engine, hTransform);
- newTrans->setTransformInfo(transInfo);
- transform = ScColorTransform(dynamic_cast<ScColorTransformData*>(newTrans));
+ hTransform = cmsCreateTransform(lcmsInputProf->m_profileHandle , lcmsInputFmt,
+ lcmsOutputProf->m_profileHandle, lcmsOutputFmt,
+ lcmsIntent, lcmsFlags | cmsFLAGS_LOWRESPRECALC);
+ if (hTransform)
+ {
+ ScLcmsColorTransformImpl* newTrans = new ScLcmsColorTransformImpl(engine, hTransform);
+ newTrans->setTransformInfo(transInfo);
+ transform = ScColorTransform(dynamic_cast<ScColorTransformData*>(newTrans));
+ }
}
+ catch (lcmsException& e)
+ {
+ std::cerr << e.what() << std::endl;
+ if (transform.isNull() && hTransform)
+ cmsDeleteTransform(hTransform);
+ transform = ScColorTransform();
+ }
+ cmsSetErrorHandler(NULL);
}
return transform;
}
@@ -310,16 +386,29 @@
transform = m_transformPool.findTransform(transInfo);
if (transform.isNull())
{
- cmsHTRANSFORM hTransform = cmsCreateProofingTransform(lcmsInputProf->m_profileHandle , lcmsInputFmt,
- lcmsOutputProf->m_profileHandle, lcmsOutputFmt,
- lcmsProofingProf->m_profileHandle, lcmsIntent,
- lcmsPrfIntent, lcmsFlags | cmsFLAGS_SOFTPROOFING);
- if (hTransform)
+ cmsSetErrorHandler(&cmsErrorHandler);
+ cmsHTRANSFORM hTransform = NULL;
+ try
{
- ScLcmsColorTransformImpl* newTrans = new ScLcmsColorTransformImpl(engine, hTransform);
- newTrans->setTransformInfo(transInfo);
- transform = ScColorTransform(dynamic_cast<ScColorTransformData*>(newTrans));
+ hTransform = cmsCreateProofingTransform(lcmsInputProf->m_profileHandle , lcmsInputFmt,
+ lcmsOutputProf->m_profileHandle, lcmsOutputFmt,
+ lcmsProofingProf->m_profileHandle, lcmsIntent,
+ lcmsPrfIntent, lcmsFlags | cmsFLAGS_SOFTPROOFING);
+ if (hTransform)
+ {
+ ScLcmsColorTransformImpl* newTrans = new ScLcmsColorTransformImpl(engine, hTransform);
+ newTrans->setTransformInfo(transInfo);
+ transform = ScColorTransform(dynamic_cast<ScColorTransformData*>(newTrans));
+ }
}
+ catch (lcmsException& e)
+ {
+ std::cerr << e.what() << std::endl;
+ if (transform.isNull() && hTransform)
+ cmsDeleteTransform(hTransform);
+ transform = ScColorTransform();
+ }
+ cmsSetErrorHandler(NULL);
}
}
else
@@ -343,15 +432,28 @@
transform = m_transformPool.findTransform(transInfo);
if (transform.isNull())
{
- cmsHTRANSFORM hTransform = cmsCreateTransform(lcmsInputProf->m_profileHandle , lcmsInputFmt,
- lcmsOutputProf->m_profileHandle, lcmsOutputFmt,
- lcmsPrfIntent, lcmsFlags | cmsFLAGS_LOWRESPRECALC);
- if (hTransform)
+ cmsSetErrorHandler(&cmsErrorHandler);
+ cmsHTRANSFORM hTransform = NULL;
+ try
{
- ScLcmsColorTransformImpl* newTrans = new ScLcmsColorTransformImpl(engine, hTransform);
- newTrans->setTransformInfo(transInfo);
- transform = ScColorTransform(dynamic_cast<ScColorTransformData*>(newTrans));
+ hTransform = cmsCreateTransform(lcmsInputProf->m_profileHandle , lcmsInputFmt,
+ lcmsOutputProf->m_profileHandle, lcmsOutputFmt,
+ lcmsPrfIntent, lcmsFlags | cmsFLAGS_LOWRESPRECALC);
+ if (hTransform)
+ {
+ ScLcmsColorTransformImpl* newTrans = new ScLcmsColorTransformImpl(engine, hTransform);
+ newTrans->setTransformInfo(transInfo);
+ transform = ScColorTransform(dynamic_cast<ScColorTransformData*>(newTrans));
+ }
}
+ catch (lcmsException& e)
+ {
+ std::cerr << e.what() << std::endl;
+ if (transform.isNull() && hTransform)
+ cmsDeleteTransform(hTransform);
+ transform = ScColorTransform();
+ }
+ cmsSetErrorHandler(NULL);
}
}
return transform;
@@ -427,7 +529,7 @@
int ScLcmsColorMngtEngineImpl::cmsErrorHandler(int /*ErrorCode*/, const char *ErrorText)
{
- std::cerr << "Littlecms : " << ErrorText << std::endl;
- longjmp(cmsJumpBuffer, 1);
+ std::string msg = std::string("Littlecms : ") + ErrorText;
+ throw lcmsException(msg.c_str());
return 1;
}
Index: scribus/colormngt/sccolorprofile.cpp
===================================================================
--- scribus/colormngt/sccolorprofile.cpp (revision 14178)
+++ scribus/colormngt/sccolorprofile.cpp (revision 14179)
@@ -17,22 +17,30 @@
icColorSpaceSignature ScColorProfile::colorSpace() const
{
- return m_data->colorSpace();
+ if (m_data)
+ return m_data->colorSpace();
+ return ((icColorSpaceSignature) 0);
}
icProfileClassSignature ScColorProfile::deviceClass() const
{
- return m_data->deviceClass();
+ if (m_data)
+ return m_data->deviceClass();
+ return ((icProfileClassSignature) 0);
}
QString ScColorProfile::profilePath() const
{
- return m_data->path();
+ if (m_data)
+ return m_data->path();
+ return QString();
}
QString ScColorProfile::productDescription() const
{
- return m_data->productDescription();
+ if (m_data)
+ return m_data->productDescription();
+ return QString();
}
bool ScColorProfile::operator==(const ScColorProfile& other) const
Index: scribus/colormngt/sclcmscolormngtengineimpl.h
===================================================================
--- scribus/colormngt/sclcmscolormngtengineimpl.h (revision 14178)
+++ scribus/colormngt/sclcmscolormngtengineimpl.h (revision 14179)
@@ -8,7 +8,7 @@
#ifndef SCLCMSCOLORMNGTENGINEIMPL_H
#define SCLCMSCOLORMNGTENGINEIMPL_H
-#include <setjmp.h>
+#include <stdexcept>
#include "lcms.h"
#include "sccolormngtenginedata.h"
@@ -54,12 +54,12 @@
static DWORD translateFormatToLcmsFormat(eColorFormat format);
static int translateIntentToLcmsIntent(eRenderIntent intent, eRenderIntent defaut = Intent_Relative_Colorimetric);
- // (Nasty) error handling : get rid of that in lcms2
- /*!
- \brief Jump buffer used by cmsErrorHandler, must be set with the setjmp() function
- * before cmsErrorHandler may be called
- */
- static jmp_buf cmsJumpBuffer;
+ // Exception class thrown by cmsErrorHandler
+ class lcmsException : public std::runtime_error
+ {
+ public :
+ lcmsException(const char* msg) : std::runtime_error(msg) {}
+ };
/*!
\brief Simple error handler for use in conjunction with littlecms
Index: scribus/scribusdoc.cpp
===================================================================
--- scribus/scribusdoc.cpp (revision 14178)
+++ scribus/scribusdoc.cpp (revision 14179)
@@ -35,7 +35,6 @@
#include <QProgressBar>
#include "canvas.h"
-#include "cmserrorhandling.h"
#include "colorblind.h"
#include "commonstrings.h"
#include "fileloader.h"
@@ -81,7 +80,6 @@
#include "undostate.h"
#include "units.h"
#include "util.h"
-#include "util_cms.h"
#include "util_icon.h"
#include "util_math.h"
@@ -652,24 +650,6 @@
{
HasCMS = false;
ScColorProfile inputProf;
- cmsErrorAction(LCMS_ERROR_ABORT);
- if (setjmp(cmsJumpBuffer))
- {
- // Reset to the default handler otherwise may enter a loop
- // if an error occur afterwards
- cmsSetErrorHandler(NULL);
- cmsErrorAction(LCMS_ERROR_IGNORE);
- CloseCMSProfiles();
- cmsErrorAction(LCMS_ERROR_ABORT);
- CMSSettings.CMSinUse = false;
- QString message = tr("An error occurred while opening ICC profiles, color management is not enabled." );
- if (ScCore->usingGUI())
- QMessageBox::warning(m_ScMW, CommonStrings::trWarning, message, QMessageBox::Ok, 0, 0);
- else
- qWarning( "%s", message.toLocal8Bit().data() );
- return false;
- }
- cmsSetErrorHandler(&cmsErrorHandler);
colorEngine = colorMngtEngineFactory.createDefaultEngine();
ScColorMngtStrategy colorStrategy;
@@ -686,7 +666,6 @@
if ((!DocInputRGBProf) || (!DocInputCMYKProf) || (!DocOutputProf) || (!DocPrinterProf) || (!DocInputImageCMYKProf) || (!DocInputImageRGBProf))
{
CMSSettings.CMSinUse = false;
- cmsSetErrorHandler(NULL);
return false;
}
@@ -744,7 +723,7 @@
stdProofGC = colorEngine.createProofingTransform(inputProfRGB, Format_RGB_16,
DocOutputProf, Format_RGB_16,
DocPrinterProf, IntentColors,
- Intent_Relative_Colorimetric, dcmsFlags| cmsFLAGS_GAMUTCHECK);
+ Intent_Relative_Colorimetric, dcmsFlags| Ctf_GamutCheck);
stdProofCMYK = colorEngine.createProofingTransform(inputProfCMYK, Format_CMYK_16,
DocOutputProf, Format_RGB_16,
DocPrinterProf, IntentColors,
@@ -753,7 +732,7 @@
DocOutputProf, Format_RGB_16,
DocPrinterProf,
IntentColors,
- Intent_Relative_Colorimetric, dcmsFlags | cmsFLAGS_GAMUTCHECK);
+ Intent_Relative_Colorimetric, dcmsFlags | Ctf_GamutCheck);
if (static_cast<int>(DocInputRGBProf.colorSpace()) == icSigRgbData)
CMSSettings.ComponentsInput2 = 3;
@@ -774,7 +753,19 @@
if (static_cast<int>(DocPrinterProf.colorSpace()) == icSigCmyData)
CMSSettings.ComponentsPrinter = 3;
- cmsSetErrorHandler(NULL);
+ bool success = (stdTransRGBMon && stdTransCMYKMon && stdProofImg && stdProofImgCMYK &&
+ stdTransImg && stdTransRGB && stdTransCMYK && stdProof &&
+ stdProofGC && stdProofCMYK && stdProofCMYKGC);
+ if (!success)
+ {
+ CloseCMSProfiles();
+ CMSSettings.CMSinUse = false;
+ QString message = tr("An error occurred while opening ICC profiles, color management is not enabled." );
+ if (ScCore->usingGUI())
+ QMessageBox::warning(m_ScMW, CommonStrings::trWarning, message, QMessageBox::Ok, 0, 0);
+ else
+ qWarning( "%s", message.toLocal8Bit().data() );
+ }
return true;
}
Index: scribus/scdocoutput_ps2.cpp
===================================================================
--- scribus/scdocoutput_ps2.cpp (revision 14178)
+++ scribus/scdocoutput_ps2.cpp (revision 14179)
@@ -8,15 +8,12 @@
#include "scdocoutput_ps2.h"
#include "scpageoutput_ps2.h"
#include "scribuscore.h"
-#include "cmserrorhandling.h"
#include "commonstrings.h"
#include "scribusdoc.h"
#include "page.h"
using namespace std;
-#include CMS_INC
-
ScDocOutput_Ps2::ScDocOutput_Ps2(ScribusDoc* doc, QString fileName, vector<int>& pageNumbers, QRect& clip, ScPs2OutputParams& options)
{
m_doc = doc;
@@ -77,17 +74,6 @@
bool success = false;
if (!m_options.outputProfile.isEmpty() && QFile::exists(m_options.outputProfile))
{
- cmsErrorAction(LCMS_ERROR_ABORT);
- if (setjmp(cmsJumpBuffer))
- {
- cmsSetErrorHandler(NULL);
- cmsErrorAction(LCMS_ERROR_ABORT);
- m_lastError = QObject::tr("An error occurred while initializing icc transforms");
- qWarning( "%s", m_lastError.toLocal8Bit().data() );
- return false;
- }
- cmsSetErrorHandler(&cmsErrorHandler);
-
int dcmsflags = 0;
if (m_doc->BlackPoint)
dcmsflags |= Ctf_BlackPointCompensation;
@@ -119,8 +105,15 @@
outputDataTypeColors, m_doc->IntentColors, dcmsflags);
m_options.cmykToOutputImageTransform = engine.createTransform(m_doc->DocInputRGBProf, Format_CMYK_8 , m_options.hProfile,
outputDataTypeImages, m_doc->IntentImages, dcmsflags);
- cmsSetErrorHandler(NULL);
- success = true;
+
+ success = (m_options.rgbToOutputColorTransform && m_options.rgbToOutputImageTransform &&
+ m_options.cmykToOutputColorTransform && m_options.cmykToOutputImageTransform );
+ if (!success)
+ {
+ m_lastError = QObject::tr("An error occurred while initializing icc transforms");
+ qWarning( "%s", m_lastError.toLocal8Bit().data() );
+ return false;
+ }
}
return success;
}
Index: scribus/scimage.cpp
===================================================================
--- scribus/scimage.cpp (revision 14178)
+++ scribus/scimage.cpp (revision 14179)
@@ -33,17 +33,16 @@
#include <cstdlib>
#include <memory>
#include <setjmp.h>
-//#include CMS_INC
-#include "util_cms.h"
+
#include "commonstrings.h"
#include "exif.h"
-#include "util_ghostscript.h"
-#include "rawimage.h"
#include "sccolorengine.h"
+#include "scstreamfilter.h"
#include "util.h"
#include "util_color.h"
#include "util_formats.h"
-#include "scstreamfilter.h"
+#include "util_ghostscript.h"
+#include "rawimage.h"
extern "C"
{
@@ -1927,8 +1926,8 @@
{
Q_ASSERT(profile);
Q_ASSERT(components);
+ ScColorProfile prof;
ScImgDataLoader* pDataLoader = NULL;
- cmsHPROFILE prof = 0;
profile->resize(0);
*components = 0;
@@ -1956,18 +1955,17 @@
QByteArray embeddedProfile = pDataLoader->embeddedProfile();
if (embeddedProfile.size())
{
- prof = cmsOpenProfileFromMem(embeddedProfile.data(), embeddedProfile.size());
+ prof = ScCore->defaultEngine.openProfileFromMem(embeddedProfile);
if (prof)
{
- if (static_cast<int>(cmsGetColorSpace(prof)) == icSigRgbData)
+ if (static_cast<int>(prof.colorSpace()) == icSigRgbData)
*components = 3;
- if (static_cast<int>(cmsGetColorSpace(prof)) == icSigCmykData)
+ if (static_cast<int>(prof.colorSpace()) == icSigCmykData)
*components = 4;
- if (static_cast<int>(cmsGetColorSpace(prof)) == icSigGrayData)
+ if (static_cast<int>(prof.colorSpace()) == icSigGrayData)
*components = 1;
*profile = embeddedProfile;
}
- cmsCloseProfile(prof);
}
delete pDataLoader;
}
@@ -2263,10 +2261,10 @@
// JG : this line overwrite image profile info and should not be needed here!!!!
// imgInfo = pDataLoader->imageInfoRecord();
}
- LPBYTE ptr2 = NULL;
+ uchar* ptr2 = NULL;
for (int i = 0; i < height(); i++)
{
- LPBYTE ptr = scanLine(i);
+ uchar* ptr = scanLine(i);
if (extensionIndicatesPSD(ext) || extensionIndicatesTIFF(ext) || pDataLoader->useRawImage())
ptr2 = pDataLoader->r_image.scanLine(i);
if ( inputProfFormat == Format_GRAY_8 && (reqType != CMYKData) )
Index: scribus/pslib.cpp
===================================================================
--- scribus/pslib.cpp (revision 14178)
+++ scribus/pslib.cpp (revision 14179)
@@ -22,7 +22,6 @@
***************************************************************************/
#include "pslib.h"
-#include <cmath>
#include <QFileInfo>
#include <QImage>
@@ -56,7 +55,6 @@
#include "scstreamfilter_flate.h"
#include "ui/multiprogressdialog.h"
#include "util.h"
-#include "util_cms.h"
#include "util_formats.h"
#include "util_math.h"
@@ -3645,8 +3643,8 @@
s1 = qRound(s1 * shade / 100.0);
v1 = qRound(v1 * shade / 100.0);
k1 = qRound(k1 * shade / 100.0);
- WORD inC[4];
- WORD outC[4];
+ unsigned short inC[4];
+ unsigned short outC[4];
inC[0] = h1 * 257;
inC[1] = s1 * 257;
inC[2] = v1 * 257;
More information about the scribus-commit
mailing list