LibGfx: Use a more explicit formula in Color::from_linear_srgb

NFC. I prefer having the constants expanded, it makes it easier to trace
them back to the initial formula.
This commit is contained in:
Lucas CHOLLET 2024-11-14 00:23:37 -05:00 committed by Andreas Kling
parent a59d9a3986
commit f949334a9a
Notes: github-actions[bot] 2024-11-16 09:31:01 +00:00

View file

@ -399,7 +399,9 @@ Vector<Color> Color::tints(u32 steps, float max) const
Color Color::from_linear_srgb(float red, float green, float blue, float alpha)
{
auto linear_to_srgb = [](float c) {
return c >= 0.0031308f ? 1.055f * pow(c, 0.4166666f) - 0.055f : 12.92f * c;
if (c <= 0.04045 / 12.92)
return c * 12.92;
return pow(c, 10. / 24) * 1.055 - 0.055;
};
red = linear_to_srgb(red) * 255.f;