ScColorProfile ScLcmsColorMgmtEngineImpl::createProfile_Lab(ScColorMgmtEngine& engine)
{
	QString internalProfilePath("memprofile://Internal Lab profile");
	ScColorProfile profile = m_profileCache->profile(internalProfilePath);
	if (!profile.isNull())
		return profile;

	cmsHPROFILE lcmsProf = NULL;
	cmsSetErrorHandler(&cmsErrorHandler);
	try
	{
		lcmsProf = cmsCreateLabProfile(NULL);
		if (lcmsProf)
		{
			ScLcmsColorProfileImpl* profData = new ScLcmsColorProfileImpl(engine, lcmsProf);
			profData->m_profilePath = internalProfilePath;
			profile = ScColorProfile(dynamic_cast<ScColorProfileData*>(profData));
			m_profileCache->addProfile(profile);
		}
		if (profile.isNull() && lcmsProf)
		{
			cmsCloseProfile(lcmsProf);
			lcmsProf = NULL;
		}
	}
	catch (lcmsException& e)
	{
		std::cerr << e.what() << std::endl;
		if (profile.isNull() && lcmsProf)
			cmsCloseProfile(lcmsProf);
		profile = ScColorProfile();
	}
	cmsSetErrorHandler(NULL);
	return profile;
}
ScColorProfile ScLcmsColorMgmtEngineImpl::openProfileFromMem(ScColorMgmtEngine& engine, const QByteArray& data)
{
	ScColorProfile profile;
	cmsHPROFILE lcmsProf = NULL;
	cmsSetErrorHandler(&cmsErrorHandler);
	try
	{
		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;
		}
	}
	catch (lcmsException& e)
	{
		std::cerr << e.what() << std::endl;
		if (profile.isNull() && lcmsProf)
			cmsCloseProfile(lcmsProf);
		profile = ScColorProfile();
	}
	cmsSetErrorHandler(NULL);
	return profile;
}
void ScribusCore::ResetDefaultColorTransforms(void)
{
	defaultRGBProfile  = ScColorProfile();
	defaultCMYKProfile = ScColorProfile();
	defaultRGBToScreenSolidTrans = ScColorTransform();
	defaultRGBToScreenImageTrans = ScColorTransform();
	defaultCMYKToScreenImageTrans = ScColorTransform();
	defaultRGBToCMYKTrans = ScColorTransform();
	defaultCMYKToRGBTrans = ScColorTransform();
}
ScColorProfile ScLcms2ColorMgmtEngineImpl::openProfileFromFile(ScColorMgmtEngine& engine, const QString& filePath)
{
	// Search profile in profile cache first
	ScColorProfile profile = m_profileCache->profile(filePath);
	if (!profile.isNull())
		return profile;
	cmsHPROFILE lcmsProf = NULL;
	QFile file(filePath);
	if (file.open(QFile::ReadOnly))
	{
		// We do not use lcms cmsOpenProfileFromFile() to avoid limitations
		// of I/O on 8bit filenames on Windows
		QByteArray data = file.readAll();
		if (!data.isEmpty())
		{
			lcmsProf = cmsOpenProfileFromMem(data.data(), data.size());
			if (lcmsProf)
			{
				ScLcms2ColorProfileImpl* profData = new ScLcms2ColorProfileImpl(engine, lcmsProf);
				profData->m_profileData = data;
				profData->m_profilePath = filePath;
				profile = ScColorProfile(dynamic_cast<ScColorProfileData*>(profData));
				m_profileCache->addProfile(profile);
			}
			if (profile.isNull() && lcmsProf)
			{
				cmsCloseProfile(lcmsProf);
				lcmsProf = NULL;
			}
		}
		file.close();
	}
	return profile;
}
ScColorProfile ScColorProfileCache::profile(const QString& profilePath)
{
	ScColorProfile profile;
	QMap<QString, QWeakPointer<ScColorProfileData> >::iterator iter = m_profileMap.find(profilePath);
	if (iter != m_profileMap.end())
		profile = ScColorProfile(iter.value());
	return profile;
}
ScColorProfile ScLcms2ColorMgmtEngineImpl::openProfileFromMem(ScColorMgmtEngine& engine, const QByteArray& data)
{
	ScColorProfile profile;
	cmsHPROFILE	lcmsProf = cmsOpenProfileFromMem((const void *) data.data(), data.size());
	if (lcmsProf)
	{
		ScLcms2ColorProfileImpl* profData = new ScLcms2ColorProfileImpl(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;
	}
	return profile;
}
ScColorProfile ScLcms2ColorMgmtEngineImpl::createProfile_Lab(ScColorMgmtEngine& engine)
{
	QString internalProfilePath("memprofile://Internal Lab profile");
	ScColorProfile profile = m_profileCache->profile(internalProfilePath);
	if (!profile.isNull())
		return profile;

	cmsHPROFILE lcmsProf = cmsCreateLab2Profile(NULL);
	if (lcmsProf)
	{
		ScLcms2ColorProfileImpl* profData = new ScLcms2ColorProfileImpl(engine, lcmsProf);
		profData->m_profilePath = internalProfilePath;
		profile = ScColorProfile(dynamic_cast<ScColorProfileData*>(profData));
		m_profileCache->addProfile(profile);
	}
	if (profile.isNull() && lcmsProf)
	{
		cmsCloseProfile(lcmsProf);
		lcmsProf = NULL;
	}
	return profile;
}
ScColorProfile ScColorSpace::profile() const
{
	if (m_data)
		return m_data->profile();
	return ScColorProfile();
}
Example #9
0
ScColorProfile CMSettings::printerProfile() const
{
	if (m_Doc)
		return m_Doc->DocPrinterProf;
	return ScColorProfile();
}
Example #10
0
ScColorProfile CMSettings::monitorProfile() const
{
	if (m_Doc)
		return m_Doc->DocOutputProf;
	return ScColorProfile();
}
Example #11
0
ScColorProfile CMSettings::monitorProfile() const
{
	if (m_Doc)
		return m_Doc->DocDisplayProf;
	return ScColorProfile();
}