diff options
Diffstat (limited to 'src/gui/painting/qcolormatrix_p.h')
-rw-r--r-- | src/gui/painting/qcolormatrix_p.h | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/src/gui/painting/qcolormatrix_p.h b/src/gui/painting/qcolormatrix_p.h index 8854b87b41..0c85222a9a 100644 --- a/src/gui/painting/qcolormatrix_p.h +++ b/src/gui/painting/qcolormatrix_p.h @@ -29,11 +29,8 @@ class QColorVector public: QColorVector() = default; constexpr QColorVector(float x, float y, float z, float w = 0.0f) noexcept : x(x), y(y), z(z), w(w) { } - explicit constexpr QColorVector(const QPointF &chr) // from XY chromaticity - : x(chr.x() / chr.y()) - , y(1.0f) - , z((1.0f - chr.x() - chr.y()) / chr.y()) - { } + static constexpr QColorVector fromXYChromaticity(QPointF chr) + { return {float(chr.x() / chr.y()), 1.0f, float((1.0f - chr.x() - chr.y()) / chr.y())}; } float x = 0.0f; // X, x, L, or red/cyan float y = 0.0f; // Y, y, a, or green/magenta float z = 0.0f; // Z, Y, b, or blue/yellow @@ -75,8 +72,8 @@ public: // Common whitepoints: static constexpr QPointF D50Chromaticity() { return QPointF(0.34567, 0.35850); } static constexpr QPointF D65Chromaticity() { return QPointF(0.31271, 0.32902); } - static constexpr QColorVector D50() { return QColorVector(D50Chromaticity()); } - static constexpr QColorVector D65() { return QColorVector(D65Chromaticity()); } + static constexpr QColorVector D50() { return fromXYChromaticity(D50Chromaticity()); } + static constexpr QColorVector D65() { return fromXYChromaticity(D65Chromaticity()); } QColorVector xyzToLab() const { @@ -339,6 +336,12 @@ public: { 0.1351922452f, 0.7118769884f, 0.0000000000f }, { 0.0313525312f, 0.0000856627f, 0.8251883388f } }; } + static QColorMatrix toXyzFromBt2020() + { + return QColorMatrix { { 0.673447f, 0.279037f, -0.00192261f }, + { 0.165665f, 0.675339f, 0.0299835f }, + { 0.125092f, 0.0456238f, 0.797134f } }; + } friend inline bool comparesEqual(const QColorMatrix &lhs, const QColorMatrix &rhs); Q_DECLARE_EQUALITY_COMPARABLE(QColorMatrix); }; |