1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 18:28:12 +00:00

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.
This commit is contained in:
Nico Weber 2023-11-02 09:07:53 -04:00 committed by Tim Flynn
parent 641365b235
commit a207ab709a

View file

@ -257,7 +257,10 @@ constexpr Array<float, 3> convert_to_srgb(Array<float, 3> 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<NonnullRefPtr<CalRGBColorSpace>> CalRGBColorSpace::create(Document* document, Vector<Value>&& parameters)