From bcb1e548f1639d2e3181db271406b209f8e8b404 Mon Sep 17 00:00:00 2001 From: Nico Weber Date: Sat, 30 Dec 2023 23:42:47 -0500 Subject: [PATCH] LibGfx/ICC: Improve XYZ coordinates of gray colors In XYZ space, gray doesn't have three equal values. Instead, it is a line through the whitepoint. (Multiplying by the whitepoint has the same effect as multiplying the sRGB matrix with a (g, g, g) vector, since the numbers on the matrix's rows add up to the whitepoint.) Fixes the very slight red tint on all the figures in chapter 4 of the PDF 1.7 spec. --- Userland/Libraries/LibGfx/ICC/Profile.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Userland/Libraries/LibGfx/ICC/Profile.cpp b/Userland/Libraries/LibGfx/ICC/Profile.cpp index 76c0cc4456..f96ba6067c 100644 --- a/Userland/Libraries/LibGfx/ICC/Profile.cpp +++ b/Userland/Libraries/LibGfx/ICC/Profile.cpp @@ -1287,7 +1287,8 @@ ErrorOr Profile::to_pcs(ReadonlyBytes color) const // ICC v4, F.2 grayTRCTag // "connection = grayTRC[device]" float gray = evaluate_curve(grayTRCTag, color[0] / 255.f); - return FloatVector3 { gray, gray, gray }; + FloatVector3 white { pcs_illuminant().X, pcs_illuminant().Y, pcs_illuminant().Z }; + return white * gray; } // FIXME: Per ICC v4, A.1 General, this should also handle HLS, HSV, YCbCr.