Krita Source Code Documentation
Loading...
Searching...
No Matches
LcmsEnginePlugin Class Reference

#include <LcmsEnginePlugin.h>

+ Inheritance diagram for LcmsEnginePlugin:

Public Member Functions

 LcmsEnginePlugin (QObject *parent, const QVariantList &)
 

Detailed Description

Definition at line 13 of file LcmsEnginePlugin.h.

Constructor & Destructor Documentation

◆ LcmsEnginePlugin()

LcmsEnginePlugin::LcmsEnginePlugin ( QObject * parent,
const QVariantList &  )

Definition at line 77 of file LcmsEnginePlugin.cpp.

78 : QObject(parent)
79{
80 KoResourcePaths::addAssetType("icc_profiles", "data", "/color/icc");
81 KoResourcePaths::addAssetType("icc_profiles", "data", "/profiles/");
82
83 // Set the lmcs error reporting function
84 cmsSetLogErrorHandler(&lcms2LogErrorHandlerFunction);
85
87
88 // Initialise color engine
90
91 QStringList profileFilenames;
92 profileFilenames += KoResourcePaths::findAllAssets("icc_profiles", "*.icm", KoResourcePaths::Recursive);
93 profileFilenames += KoResourcePaths::findAllAssets("icc_profiles", "*.ICM", KoResourcePaths::Recursive);
94 profileFilenames += KoResourcePaths::findAllAssets("icc_profiles", "*.ICC", KoResourcePaths::Recursive);
95 profileFilenames += KoResourcePaths::findAllAssets("icc_profiles", "*.icc", KoResourcePaths::Recursive);
96
97 QStringList iccProfileDirs;
98
99#ifdef Q_OS_MAC
100 iccProfileDirs.append(QDir::homePath() + "/Library/ColorSync/Profiles/");
101 iccProfileDirs.append("/System/Library/ColorSync/Profiles/");
102 iccProfileDirs.append("/Library/ColorSync/Profiles/");
103#endif
104#ifdef Q_OS_WIN
105 QString winPath = QString::fromUtf8(qgetenv("windir"));
106 winPath.replace('\\','/');
107 iccProfileDirs.append(winPath + "/System32/Spool/Drivers/Color/");
108
109#endif
110#ifdef Q_OS_LINUX
111 iccProfileDirs.append(QDir::homePath() + "./share/color/icc");
112#endif
113
114 QStringList blackList = QStringList() << "panhexro.icm"
115 << "ctpctdmed.icc";
116
117
118 Q_FOREACH(const QString &iccProfiledir, iccProfileDirs) {
119 QDir profileDir(iccProfiledir);
120 Q_FOREACH(const QString &entry, profileDir.entryList(QStringList() << "*.icm" << "*.icc" << "*.ICM" << "*.ICC", QDir::NoDotAndDotDot | QDir::Files | QDir::Readable)) {
121 if (blackList.contains(entry.toLower())) continue;
122 profileFilenames << iccProfiledir + "/" + entry;
123 }
124 }
125
126 // Load the profiles
127 if (!profileFilenames.empty()) {
128 for (QStringList::Iterator it = profileFilenames.begin(); it != profileFilenames.end(); ++it) {
129
130 KoColorProfile *profile = new IccColorProfile(*it);
131 Q_CHECK_PTR(profile);
132
133 profile->load();
134 if (profile->valid()) {
135 //qDebug() << "Valid profile : " << profile->fileName() << profile->name();
136 registry->addProfileToMap(profile);
137 } else {
138 qDebug() << "Invalid profile : " << *it;
139 delete profile;
140 }
141 }
142 }
143
144 // ------------------- LAB ---------------------------------
145
146 KoColorProfile *labProfile = LcmsColorProfileContainer::createFromLcmsProfile(cmsCreateLab4Profile(0));
147 registry->addProfile(labProfile);
148
149 registry->add(new LabU8ColorSpaceFactory());
150 registry->add(new LabU16ColorSpaceFactory());
151 registry->add(new LabF32ColorSpaceFactory());
152
155 (KoID("LABAU8HISTO", i18n("L*a*b*/8 Histogram")), LABAColorModelID.id(), Integer8BitsColorDepthID.id()));
156
159 (KoID("LABAU16HISTO", i18n("L*a*b*/16 Histogram")), LABAColorModelID.id(), Integer16BitsColorDepthID.id()));
160
163 (KoID("LABAF32HISTO", i18n("L*a*b*/32 Histogram")), LABAColorModelID.id(), Float32BitsColorDepthID.id()));
164
165 // ------------------- RGB ---------------------------------
166
167 KoColorProfile *rgbProfile = LcmsColorProfileContainer::createFromLcmsProfile(cmsCreate_sRGBProfile());
168 registry->addProfile(rgbProfile);
169
172#ifdef HAVE_LCMS24
173#ifdef HAVE_OPENEXR
175#endif
176#endif
178
181 (KoID("RGBU8HISTO", i18n("RGBA/8 Histogram")), RGBAColorModelID.id(), Integer8BitsColorDepthID.id()));
182
185 (KoID("RGBU16HISTO", i18n("RGBA/16 Histogram")), RGBAColorModelID.id(), Integer16BitsColorDepthID.id()));
186
187#ifdef HAVE_LCMS24
188#ifdef HAVE_OPENEXR
191 (KoID("RGBF16HISTO", i18n("RGBA/F16 Histogram")), RGBAColorModelID.id(), Float16BitsColorDepthID.id()));
192#endif
193#endif
194
197 (KoID("RGF328HISTO", i18n("RGBA/F32 Histogram")), RGBAColorModelID.id(), Float32BitsColorDepthID.id()));
198
199 // ------------------- GRAY ---------------------------------
200
201 cmsToneCurve *Gamma = cmsBuildGamma(0, 2.2);
202 cmsHPROFILE hProfile = cmsCreateGrayProfile(cmsD50_xyY(), Gamma);
203 cmsFreeToneCurve(Gamma);
205 registry->addProfile(defProfile);
206
207 registry->add(new GrayAU8ColorSpaceFactory());
208 registry->add(new GrayAU16ColorSpaceFactory());
209#ifdef HAVE_LCMS24
210#ifdef HAVE_OPENEXR
211 registry->add(new GrayF16ColorSpaceFactory());
212#endif
213#endif
214 registry->add(new GrayF32ColorSpaceFactory());
215
218 (KoID("GRAYA8HISTO", i18n("GRAY/8 Histogram")), GrayAColorModelID.id(), Integer8BitsColorDepthID.id()));
219
222 (KoID("GRAYA16HISTO", i18n("GRAY/16 Histogram")), GrayAColorModelID.id(), Integer16BitsColorDepthID.id()));
223#ifdef HAVE_LCMS24
224#ifdef HAVE_OPENEXR
227 (KoID("GRAYF16HISTO", i18n("GRAYF/F16 Histogram")), GrayAColorModelID.id(), Float16BitsColorDepthID.id()));
228#endif
229#endif
230
233 (KoID("GRAYAF32HISTO", i18n("GRAY/F32 float Histogram")), GrayAColorModelID.id(), Float32BitsColorDepthID.id()));
234
235 // ------------------- CMYK ---------------------------------
236
237 registry->add(new CmykU8ColorSpaceFactory());
238 registry->add(new CmykU16ColorSpaceFactory());
239 registry->add(new CmykF32ColorSpaceFactory());
240
243 (KoID("CMYK8HISTO", i18n("CMYK/8 Histogram")), CMYKAColorModelID.id(), Integer8BitsColorDepthID.id()));
244
247 (KoID("CMYK16HISTO", i18n("CMYK/16 Histogram")), CMYKAColorModelID.id(), Integer16BitsColorDepthID.id()));
248
251 (KoID("CMYKF32HISTO", i18n("CMYK/F32 Histogram")), CMYKAColorModelID.id(), Float32BitsColorDepthID.id()));
252
253 // ------------------- XYZ ---------------------------------
254
255 KoColorProfile *xyzProfile = LcmsColorProfileContainer::createFromLcmsProfile(cmsCreateXYZProfile());
256 registry->addProfile(xyzProfile);
257
258 registry->add(new XyzU8ColorSpaceFactory());
259 registry->add(new XyzU16ColorSpaceFactory());
260#ifdef HAVE_LCMS24
261#ifdef HAVE_OPENEXR
262 registry->add(new XyzF16ColorSpaceFactory());
263#endif
264#endif
265 registry->add(new XyzF32ColorSpaceFactory());
266
269 (KoID("XYZ8HISTO", i18n("XYZ/8 Histogram")), XYZAColorModelID.id(), Integer8BitsColorDepthID.id()));
270
273 (KoID("XYZ16HISTO", i18n("XYZ/16 Histogram")), XYZAColorModelID.id(), Integer16BitsColorDepthID.id()));
274
275#ifdef HAVE_LCMS24
276#ifdef HAVE_OPENEXR
279 (KoID("XYZF16HISTO", i18n("XYZ/F16 Histogram")), XYZAColorModelID.id(), Float16BitsColorDepthID.id()));
280#endif
281#endif
282
285 (KoID("XYZF32HISTO", i18n("XYZF32 Histogram")), XYZAColorModelID.id(), Float32BitsColorDepthID.id()));
286
287 // ------------------- YCBCR ---------------------------------
288
289 // KoColorProfile *yCbCrProfile = LcmsColorProfileContainer::createFromLcmsProfile(cmsCreateYCBCRProfile());
290 // registry->addProfile(yCbCrProfile);
291
292 registry->add(new YCbCrU8ColorSpaceFactory());
293 registry->add(new YCbCrU16ColorSpaceFactory());
294 registry->add(new YCbCrF32ColorSpaceFactory());
295
298 (KoID("YCBCR8HISTO", i18n("YCbCr/8 Histogram")), YCbCrAColorModelID.id(), Integer8BitsColorDepthID.id()));
299
302 (KoID("YCBCR16HISTO", i18n("YCbCr/16 Histogram")), YCbCrAColorModelID.id(), Integer16BitsColorDepthID.id()));
303
306 (KoID("YCBCRF32HISTO", i18n("YCbCr/F32 Histogram")), YCbCrAColorModelID.id(), Float32BitsColorDepthID.id()));
307
308 // Add profile alias for default profile from lcms1
309 registry->addProfileAlias("sRGB built-in - (lcms internal)", "sRGB built-in");
310 registry->addProfileAlias("gray built-in - (lcms internal)", "gray built-in");
311 registry->addProfileAlias("Lab identity built-in - (lcms internal)", "Lab identity built-in");
312 registry->addProfileAlias("XYZ built-in - (lcms internal)", "XYZ identity built-in");
313
314#if defined(HAVE_LCMS_FAST_FLOAT_PLUGIN)
315 cmsPlugin(cmsFastFloatExtensions());
316#endif
317}
QList< QString > QStringList
const KoID Float32BitsColorDepthID("F32", ki18n("32-bit float/channel"))
const KoID YCbCrAColorModelID("YCbCrA", ki18n("YCbCr/Alpha"))
const KoID GrayAColorModelID("GRAYA", ki18n("Grayscale/Alpha"))
const KoID XYZAColorModelID("XYZA", ki18n("XYZ/Alpha"))
const KoID Float16BitsColorDepthID("F16", ki18n("16-bit float/channel"))
const KoID Integer8BitsColorDepthID("U8", ki18n("8-bit integer/channel"))
const KoID Integer16BitsColorDepthID("U16", ki18n("16-bit integer/channel"))
const KoID CMYKAColorModelID("CMYKA", ki18n("CMYK/Alpha"))
const KoID LABAColorModelID("LABA", ki18n("L*a*b*/Alpha"))
const KoID RGBAColorModelID("RGBA", ki18n("RGB/Alpha"))
void lcms2LogErrorHandlerFunction(cmsContext, cmsUInt32Number ErrorCode, const char *Text)
static KoColorSpaceEngineRegistry * instance()
static KoHistogramProducerFactoryRegistry * instance()
Definition KoID.h:30
QString id() const
Definition KoID.cpp:63
static void addAssetType(const QString &type, const char *basetype, const QString &relativeName, bool priority=true)
static QStringList findAllAssets(const QString &type, const QString &filter=QString(), SearchOptions options=NoSearchOptions)
static IccColorProfile * createFromLcmsProfile(const cmsHPROFILE profile)
virtual bool load()
virtual bool valid() const =0
void addProfileAlias(const QString &name, const QString &to)
static KoColorSpaceRegistry * instance()
void add(KoColorSpaceFactory *item)
void addProfileToMap(KoColorProfile *p)
void addProfile(KoColorProfile *profile)

References KoColorSpaceRegistry::add(), KoGenericRegistry< T >::add(), KoResourcePaths::addAssetType(), KoColorSpaceRegistry::addProfile(), KoColorSpaceRegistry::addProfileAlias(), KoColorSpaceRegistry::addProfileToMap(), CMYKAColorModelID, LcmsColorProfileContainer::createFromLcmsProfile(), KoResourcePaths::findAllAssets(), Float16BitsColorDepthID, Float32BitsColorDepthID, GrayAColorModelID, KoID::id(), KoColorSpaceEngineRegistry::instance(), KoColorSpaceRegistry::instance(), KoHistogramProducerFactoryRegistry::instance(), Integer16BitsColorDepthID, Integer8BitsColorDepthID, LABAColorModelID, lcms2LogErrorHandlerFunction(), KoColorProfile::load(), KoResourcePaths::Recursive, RGBAColorModelID, KoColorProfile::valid(), XYZAColorModelID, and YCbCrAColorModelID.


The documentation for this class was generated from the following files: