57
type(IccProfile::InvalidType),
59
type = IccProfile::InvalidType;
62
62
IccProfilePriv(const IccProfilePriv& other)
69
IccProfilePriv &operator=(const IccProfilePriv& other)
69
IccProfilePriv& operator=(const IccProfilePriv& other)
72
72
filePath = other.filePath;
133
133
// ----------------------------------------------------------------------------------
135
135
IccProfile::IccProfile()
140
140
IccProfile::IccProfile(const QByteArray& data)
141
: d(new IccProfilePriv)
141
: d(new IccProfilePriv)
146
146
IccProfile::IccProfile(const QString& filePath)
147
: d(new IccProfilePriv)
147
: d(new IccProfilePriv)
149
149
d->filePath = filePath;
152
IccProfile::IccProfile(const char *location, const QString& relativePath)
152
IccProfile::IccProfile(const char* location, const QString& relativePath)
155
155
QString filePath = KStandardDirs::locate(location, relativePath);
156
157
if (filePath.isNull())
158
159
kError() << "The bundled profile" << relativePath << "cannot be found. Check your installation.";
161
163
d = new IccProfilePriv;
162
164
d->filePath = filePath;
171
173
IccProfile IccProfile::adobeRGB()
173
175
QString path = static_d->adobeRGBPath;
174
177
if (path.isEmpty())
175
179
path = KStandardDirs::locate("data", "libkdcraw/profiles/compatibleWithAdobeRGB1998.icc");
177
182
if (path.isEmpty()) // this one has a wrong whitepoint. Remove when sufficiently recent libkdcraw is a digikam dependency.
178
184
path = KStandardDirs::locate("data", "libkdcraw/profiles/adobergb.icm");
180
187
return IccProfile(path);
230
237
bool IccProfile::operator==(const IccProfile& other) const
232
239
if (d == other.d)
235
244
if (d && other.d)
237
246
if (!d->filePath.isNull() || !other.d->filePath.isNull())
238
248
return d->filePath == other.d->filePath;
239
251
if (!d->data.isNull() || other.d->data.isNull())
240
253
return d->data == other.d->data;
245
260
bool IccProfile::isSameProfileAs(IccProfile& other)
247
262
if (d == other.d)
250
267
if (d && other.d)
253
270
return data() == other.data();
258
276
QByteArray IccProfile::data()
261
280
return QByteArray();
263
283
if (!d->data.isEmpty())
331
368
QString IccProfile::description()
334
372
return QString();
336
375
if (!d->description.isNull())
337
377
return d->description;
340
382
return QString();
343
const char *desc = cmsTakeProductDesc(d->handle);
386
const char* desc = cmsTakeProductDesc(d->handle);
345
388
if (desc && desc[0] != '\0')
346
390
d->description = QString::fromLatin1(desc);
348
393
return d->description;
394
446
bool IccProfile::writeToFile(const QString& filePath)
399
453
QByteArray profile = data();
400
455
if (!profile.isEmpty())
402
457
QFile file(filePath);
403
459
if ( !file.open(QIODevice::WriteOnly) )
406
464
if (file.write(profile) == -1)
415
void *IccProfile::handle() const
476
void* IccProfile::handle() const
420
483
return d->handle;
428
491
paths << KGlobal::dirs()->findDirs("data", "color/icc");
432
#elif defined (Q_WS_MAC)
436
// XDG data dirs, including /usr/share/color/icc
437
QStringList dataDirs = QString::fromLocal8Bit(getenv("XDG_DATA_DIRS")).split(':', QString::SkipEmptyParts);
439
if (!dataDirs.contains(QLatin1String("/usr/share")))
440
dataDirs << "/usr/share";
442
if (!dataDirs.contains(QLatin1String("/usr/local/share")))
443
dataDirs << "/usr/local/share";
445
foreach (const QString& dataDir, dataDirs)
447
candidates << dataDir + "/color/icc";
451
QString dataHomeDir = QString::fromLocal8Bit(getenv("XDG_DATA_HOME"));
452
if (!dataHomeDir.isEmpty())
454
candidates << dataHomeDir + "/color/icc";
455
candidates << dataHomeDir + "/icc";
458
// home dir directories
459
candidates << QDir::homePath() + "/.local/share/color/icc/";
460
candidates << QDir::homePath() + "/.local/share/icc/";
461
candidates << QDir::homePath() + "/.color/icc/";
495
#elif defined (Q_WS_MAC)
499
// XDG data dirs, including /usr/share/color/icc
500
QStringList dataDirs = QString::fromLocal8Bit(getenv("XDG_DATA_DIRS")).split(':', QString::SkipEmptyParts);
502
if (!dataDirs.contains(QLatin1String("/usr/share")))
504
dataDirs << "/usr/share";
507
if (!dataDirs.contains(QLatin1String("/usr/local/share")))
509
dataDirs << "/usr/local/share";
512
foreach (const QString& dataDir, dataDirs)
514
candidates << dataDir + "/color/icc";
518
QString dataHomeDir = QString::fromLocal8Bit(getenv("XDG_DATA_HOME"));
520
if (!dataHomeDir.isEmpty())
522
candidates << dataHomeDir + "/color/icc";
523
candidates << dataHomeDir + "/icc";
526
// home dir directories
527
candidates << QDir::homePath() + "/.local/share/color/icc/";
528
candidates << QDir::homePath() + "/.local/share/icc/";
529
candidates << QDir::homePath() + "/.color/icc/";
465
533
foreach (const QString& candidate, candidates)
467
535
QDir dir(candidate);
468
537
if (dir.exists() && dir.isReadable())
470
539
QString path = dir.canonicalPath();
471
541
if (!paths.contains(path))
475
547
//kDebug() << candidates << '\n' << paths;
480
552
void IccProfile::considerOriginalAdobeRGB(const QString& filePath)
482
554
if (!static_d->adobeRGBPath.isNull())
485
559
QFile file(filePath);
486
561
if (file.open(QIODevice::ReadOnly))
489
564
md5.update(file);
490
566
if (md5.hexDigest() == "dea88382d899d5f6e573b432473ae138")
492
568
kDebug() << "The original Adobe RGB (1998) profile has been found at" << filePath;