mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-26 17:40:27 +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
Notes:
sideshowbarker
2024-07-17 06:40:21 +09:00
Author: https://github.com/nico Commit: https://github.com/SerenityOS/serenity/commit/d577d181e3 Pull-request: https://github.com/SerenityOS/serenity/pull/22363 Reviewed-by: https://github.com/LucasChollet
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…
Reference in a new issue