summaryrefslogtreecommitdiffstats
path: root/src/gui/painting
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@qt.io>2021-02-25 12:42:08 +0100
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2021-03-03 08:29:57 +0100
commit07a65fecbff0be2a1e89399ed38bb5cf46dac33b (patch)
tree163bf296d38cecc83a624db762d01305774a3aa1 /src/gui/painting
parentee2dc9e19dfe8545b8e60a6b394ab9a5a856662f (diff)
Fix logic problems with table based grayscale ICC profiles
White-point was calculated wrongly and some tables could cause bad behavior in the tables. Change-Id: I24e8f5f3cc1306f5f898a4acbf7b008e26bd04e2 Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io> (cherry picked from commit f493d41722fc76a04f699ea26128fdf3d215d913)
Diffstat (limited to 'src/gui/painting')
-rw-r--r--src/gui/painting/qcolortransfertable_p.h8
-rw-r--r--src/gui/painting/qicc.cpp2
2 files changed, 5 insertions, 5 deletions
diff --git a/src/gui/painting/qcolortransfertable_p.h b/src/gui/painting/qcolortransfertable_p.h
index fdf68b78da..2d8f41e086 100644
--- a/src/gui/painting/qcolortransfertable_p.h
+++ b/src/gui/painting/qcolortransfertable_p.h
@@ -136,7 +136,7 @@ public:
return 1.0f;
if (!m_table16.isEmpty()) {
float v = x * 65535.0f;
- uint32_t i = std::floor(resultLargerThan * (m_tableSize - 1)) + 1;
+ uint32_t i = std::floor(resultLargerThan * (m_tableSize - 1));
for ( ; i < m_tableSize; ++i) {
if (m_table16[i] > v)
break;
@@ -145,14 +145,14 @@ public:
return 1.0f;
float y1 = m_table16[i - 1];
float y2 = m_table16[i];
- Q_ASSERT(x >= y1 && x < y2);
+ Q_ASSERT(v >= y1 && v <= y2);
float fr = (v - y1) / (y2 - y1);
return (i + fr) * (1.0f / (m_tableSize - 1));
}
if (!m_table8.isEmpty()) {
float v = x * 255.0f;
- uint32_t i = std::floor(resultLargerThan * (m_tableSize - 1)) + 1;
+ uint32_t i = std::floor(resultLargerThan * (m_tableSize - 1));
for ( ; i < m_tableSize; ++i) {
if (m_table8[i] > v)
break;
@@ -161,7 +161,7 @@ public:
return 1.0f;
float y1 = m_table8[i - 1];
float y2 = m_table8[i];
- Q_ASSERT(x >= y1 && x < y2);
+ Q_ASSERT(v >= y1 && v <= y2);
float fr = (v - y1) / (y2 - y1);
return (i + fr) * (1.0f / (m_tableSize - 1));
}
diff --git a/src/gui/painting/qicc.cpp b/src/gui/painting/qicc.cpp
index 0acd458eff..028e800c48 100644
--- a/src/gui/painting/qicc.cpp
+++ b/src/gui/painting/qicc.cpp
@@ -759,7 +759,7 @@ bool fromIccProfile(const QByteArray &data, QColorSpace *colorSpace)
} 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 y = 1.0f / (1.0f + whitePoint.z + whitePoint.x);
float x = whitePoint.x * y;
QColorSpacePrimaries primaries(QColorSpace::Primaries::SRgb);
primaries.whitePoint = QPointF(x,y);