From a207ab709a8b7f95cd8bf2a44fc9f0dc5c4ed23f Mon Sep 17 00:00:00 2001 From: Nico Weber Date: Thu, 2 Nov 2023 09:07:53 -0400 Subject: [PATCH] LibPDF: In convert_to_srgb(), also apply sRGB curve (ish) We did convert from the input space to linear space and then to linear sRGB, but we forgot to re-apply gamma. This uses the x^2.2 curve instead of the real sRGB curve for now. --- Userland/Libraries/LibPDF/ColorSpace.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Userland/Libraries/LibPDF/ColorSpace.cpp b/Userland/Libraries/LibPDF/ColorSpace.cpp index 4dcb4ae8f6..0736373090 100644 --- a/Userland/Libraries/LibPDF/ColorSpace.cpp +++ b/Userland/Libraries/LibPDF/ColorSpace.cpp @@ -257,7 +257,10 @@ constexpr Array convert_to_srgb(Array xyz) 1.0572252, }; - return matrix_multiply(conversion_matrix, xyz); + auto linear_srgb = matrix_multiply(conversion_matrix, xyz); + + // FIXME: Use the real sRGB curve by replacing this function with Gfx::ICC::sRGB().from_pcs(). + return { pow(linear_srgb[0], 1.0f / 2.2f), pow(linear_srgb[1], 1.0f / 2.2f), pow(linear_srgb[2], 1.0f / 2.2f) }; } PDFErrorOr> CalRGBColorSpace::create(Document* document, Vector&& parameters)