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)
This commit is contained in:
parent
ee2dc9e19d
commit
07a65fecbf
@ -136,7 +136,7 @@ public:
|
|||||||
return 1.0f;
|
return 1.0f;
|
||||||
if (!m_table16.isEmpty()) {
|
if (!m_table16.isEmpty()) {
|
||||||
float v = x * 65535.0f;
|
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) {
|
for ( ; i < m_tableSize; ++i) {
|
||||||
if (m_table16[i] > v)
|
if (m_table16[i] > v)
|
||||||
break;
|
break;
|
||||||
@ -145,14 +145,14 @@ public:
|
|||||||
return 1.0f;
|
return 1.0f;
|
||||||
float y1 = m_table16[i - 1];
|
float y1 = m_table16[i - 1];
|
||||||
float y2 = m_table16[i];
|
float y2 = m_table16[i];
|
||||||
Q_ASSERT(x >= y1 && x < y2);
|
Q_ASSERT(v >= y1 && v <= y2);
|
||||||
float fr = (v - y1) / (y2 - y1);
|
float fr = (v - y1) / (y2 - y1);
|
||||||
return (i + fr) * (1.0f / (m_tableSize - 1));
|
return (i + fr) * (1.0f / (m_tableSize - 1));
|
||||||
|
|
||||||
}
|
}
|
||||||
if (!m_table8.isEmpty()) {
|
if (!m_table8.isEmpty()) {
|
||||||
float v = x * 255.0f;
|
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) {
|
for ( ; i < m_tableSize; ++i) {
|
||||||
if (m_table8[i] > v)
|
if (m_table8[i] > v)
|
||||||
break;
|
break;
|
||||||
@ -161,7 +161,7 @@ public:
|
|||||||
return 1.0f;
|
return 1.0f;
|
||||||
float y1 = m_table8[i - 1];
|
float y1 = m_table8[i - 1];
|
||||||
float y2 = m_table8[i];
|
float y2 = m_table8[i];
|
||||||
Q_ASSERT(x >= y1 && x < y2);
|
Q_ASSERT(v >= y1 && v <= y2);
|
||||||
float fr = (v - y1) / (y2 - y1);
|
float fr = (v - y1) / (y2 - y1);
|
||||||
return (i + fr) * (1.0f / (m_tableSize - 1));
|
return (i + fr) * (1.0f / (m_tableSize - 1));
|
||||||
}
|
}
|
||||||
|
@ -759,7 +759,7 @@ bool fromIccProfile(const QByteArray &data, QColorSpace *colorSpace)
|
|||||||
} else {
|
} else {
|
||||||
colorspaceDPtr->primaries = QColorSpace::Primaries::Custom;
|
colorspaceDPtr->primaries = QColorSpace::Primaries::Custom;
|
||||||
// Calculate chromaticity from xyz (assuming y == 1.0f).
|
// 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;
|
float x = whitePoint.x * y;
|
||||||
QColorSpacePrimaries primaries(QColorSpace::Primaries::SRgb);
|
QColorSpacePrimaries primaries(QColorSpace::Primaries::SRgb);
|
||||||
primaries.whitePoint = QPointF(x,y);
|
primaries.whitePoint = QPointF(x,y);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user