mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-01 13:49:16 +00:00
LibGfx/TinyVG: Clamp RGBAF32 color values from 0 and 255
This commit is contained in:
parent
aa54007943
commit
10757b7787
Notes:
sideshowbarker
2024-07-17 04:10:16 +09:00
Author: https://github.com/tcl3
Commit: 10757b7787
Pull-request: https://github.com/SerenityOS/serenity/pull/21719
Reviewed-by: https://github.com/MacDue
1 changed files with 5 additions and 1 deletions
|
@ -154,7 +154,11 @@ static ErrorOr<Vector<Color>> decode_color_table(Stream& stream, ColorEncoding e
|
|||
auto green = TRY(stream.read_value<LittleEndian<f32>>());
|
||||
auto blue = TRY(stream.read_value<LittleEndian<f32>>());
|
||||
auto alpha = TRY(stream.read_value<LittleEndian<f32>>());
|
||||
return Color(red * 255, green * 255, blue * 255, alpha * 255);
|
||||
return Color(
|
||||
clamp(red * 255.0f, 0.0f, 255.0f),
|
||||
clamp(green * 255.0f, 0.0f, 255.0f),
|
||||
clamp(blue * 255.0f, 0.0f, 255.0f),
|
||||
clamp(alpha * 255.0f, 0.0f, 255.0f));
|
||||
}
|
||||
default:
|
||||
return Error::from_string_literal("Invalid TinyVG: Bad color encoding");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue