mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 02:57:44 +00:00
LibPDF: Clamp sRGB channels before converting to u8 in CalRGB code
Sometimes the numbers end up just slightly above 1.0f, which previously caused an overflow.
This commit is contained in:
parent
bdd2404453
commit
f8799885de
1 changed files with 3 additions and 3 deletions
|
@ -342,9 +342,9 @@ PDFErrorOr<Color> CalRGBColorSpace::color(ReadonlySpan<Value> arguments) const
|
||||||
auto d65_normalized = convert_to_d65(scaled_black_point_xyz);
|
auto d65_normalized = convert_to_d65(scaled_black_point_xyz);
|
||||||
auto srgb = convert_to_srgb(d65_normalized);
|
auto srgb = convert_to_srgb(d65_normalized);
|
||||||
|
|
||||||
auto red = static_cast<u8>(srgb[0] * 255.0f);
|
auto red = static_cast<u8>(clamp(srgb[0], 0.0f, 1.0f) * 255.0f);
|
||||||
auto green = static_cast<u8>(srgb[1] * 255.0f);
|
auto green = static_cast<u8>(clamp(srgb[1], 0.0f, 1.0f) * 255.0f);
|
||||||
auto blue = static_cast<u8>(srgb[2] * 255.0f);
|
auto blue = static_cast<u8>(clamp(srgb[2], 0.0f, 1.0f) * 255.0f);
|
||||||
|
|
||||||
return Color(red, green, blue);
|
return Color(red, green, blue);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue