summaryrefslogtreecommitdiffstats
path: root/src/gui
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@qt.io>2024-04-02 13:54:45 +0200
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2024-04-06 09:05:14 +0200
commit923c5145a8ea47480d49100a9865928baacad6d6 (patch)
treec80e5cd6d5d57e6b9046724a5a85840200c614e9 /src/gui
parent772fd609c6eff09bdaa44cb2ac5f913e58788fa3 (diff)
Parse grayscale ICC profile as grayscale color spaces
Removes the old hack of parsing them as a compatible RGB color space. Change-Id: I876d74ca5830b46decc15b20e8a3baa12d5e2713 Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/painting/qicc.cpp25
1 files changed, 4 insertions, 21 deletions
diff --git a/src/gui/painting/qicc.cpp b/src/gui/painting/qicc.cpp
index 8a3e8805b9..c7b9f88970 100644
--- a/src/gui/painting/qicc.cpp
+++ b/src/gui/painting/qicc.cpp
@@ -1110,8 +1110,6 @@ static bool parseRgbMatrix(const QByteArray &data, const QHash<Tag, TagEntry> &t
static bool parseGrayMatrix(const QByteArray &data, const QHash<Tag, TagEntry> &tagIndex, QColorSpacePrivate *colorspaceDPtr)
{
- // We will use sRGB primaries and fit to match the given white-point if
- // it doesn't match sRGB's.
QColorVector whitePoint;
if (!parseXyzData(data, tagIndex[Tag::wtpt], whitePoint))
return false;
@@ -1119,25 +1117,8 @@ static bool parseGrayMatrix(const QByteArray &data, const QHash<Tag, TagEntry> &
qCWarning(lcIcc) << "fromIccProfile: Invalid ICC profile - gray white-point not normalized";
return false;
}
- if (whitePoint == QColorVector::D65()) {
- colorspaceDPtr->primaries = QColorSpace::Primaries::SRgb;
- } else {
- colorspaceDPtr->primaries = QColorSpace::Primaries::Custom;
- // Calculate chromaticity from xyz (assuming y == 1.0f).
- float y = 1.0f / (1.0f + whitePoint.z + whitePoint.x);
- float x = whitePoint.x * y;
- QColorSpacePrimaries primaries(QColorSpace::Primaries::SRgb);
- primaries.whitePoint = QPointF(x,y);
- if (!primaries.areValid()) {
- qCWarning(lcIcc, "fromIccProfile: Invalid ICC profile - invalid white-point(%f, %f)", x, y);
- return false;
- }
- colorspaceDPtr->toXyz = primaries.toXyzMatrix();
- if (!colorspaceDPtr->toXyz.isValid()) {
- qCWarning(lcIcc, "fromIccProfile: Invalid ICC profile - invalid white-point(%f, %f)", x, y);
- return false;
- }
- }
+ colorspaceDPtr->primaries = QColorSpace::Primaries::Custom;
+ colorspaceDPtr->whitePoint = whitePoint;
return true;
}
@@ -1337,6 +1318,8 @@ bool fromIccProfile(const QByteArray &data, QColorSpace *colorSpace)
} else {
colorspaceDPtr->chad = QColorMatrix::chromaticAdaptation(colorspaceDPtr->whitePoint);
}
+ if (colorspaceDPtr->colorModel == QColorSpace::ColorModel::Gray)
+ colorspaceDPtr->toXyz = colorspaceDPtr->chad;
// Reset the matrix to our canonical values:
if (colorspaceDPtr->primaries != QColorSpace::Primaries::Custom)