diff --git a/Userland/Libraries/LibPDF/ColorSpace.cpp b/Userland/Libraries/LibPDF/ColorSpace.cpp index c420f4e002..a8f0383180 100644 --- a/Userland/Libraries/LibPDF/ColorSpace.cpp +++ b/Userland/Libraries/LibPDF/ColorSpace.cpp @@ -302,6 +302,9 @@ constexpr Array convert_to_srgb(Array xyz) }; auto linear_srgb = matrix_multiply(conversion_matrix, xyz); + linear_srgb[0] = clamp(linear_srgb[0], 0.0f, 1.0f); + linear_srgb[1] = clamp(linear_srgb[1], 0.0f, 1.0f); + linear_srgb[2] = clamp(linear_srgb[2], 0.0f, 1.0f); // 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) };