mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 21:37:35 +00:00
LibPDF: Clamp linear_srgb values in convert_to_srgb()
This is very crude gamut mapping, but it's better than producing NaNs when passing negative values to powf(x, 1/2.2).
This commit is contained in:
parent
3ff36855d4
commit
d577d181e3
1 changed files with 3 additions and 0 deletions
|
@ -302,6 +302,9 @@ constexpr Array<float, 3> convert_to_srgb(Array<float, 3> 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) };
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue