[PATCH] colorsapplicator: Don't allow extended RGB from OKLabToLinearSRGB
authorAkseli Lahtinen <akselmo@akselmo.dev>
Mon, 5 May 2025 18:14:08 +0000 (21:14 +0300)
committerAurélien COUDERC <coucouf@debian.org>
Tue, 20 May 2025 06:31:26 +0000 (08:31 +0200)
When reading the rgb values in OKLabToLinearSRGB, there is a chance,
when colors are tinted, for QColor::fromRgbF to return Extended RGB
colors, which can invert.
Read more at
https://doc.qt.io/qt-6/qcolor.html#the-extended-rgb-color-model

Instead, just make sure we always return regular RGB values.

BUG: 503394
FIXED-IN: 6.3

(cherry picked from commit 4329b16a96a47c310e2d2a5da6f7543f94b6d3ec)

Co-authored-by: Akseli Lahtinen <akselmo@akselmo.dev>
Gbp-Pq: Name upstream_32a7cf2a_colorsapplicator-Don-t-allow-extended-RGB-from-OKLabToLinearSRGB.patch

kcms/colors/colorsapplicator.cpp

index 6f0eeffe66626789d42b22b5bc0bf9bfc774694a..7d28889de6f0b40ae02620023477a8cc040daaae 100644 (file)
@@ -100,7 +100,7 @@ QColor OKLabToLinearSRGB(LAB lab)
     const auto g = -1.2684380046 * l + 2.6097574011 * m - 0.3413193965 * s;
     const auto b = -0.0041960863 * l - 0.7034186147 * m + 1.7076147010 * s;
 
-    return QColor::fromRgbF(r, g, b);
+    return QColor::fromRgbF(r, g, b).toRgb();
 }
 
 auto toLinearSRGB = QColorSpace(QColorSpace::SRgb).transformationToColorSpace(QColorSpace::SRgbLinear);