1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 15:37:46 +00:00

LibGfx/TinyVG: Clamp RGBAF32 color values from 0 and 255

This commit is contained in:
Tim Ledbetter 2023-11-01 17:42:42 +00:00 committed by Andreas Kling
parent aa54007943
commit 10757b7787

View file

@ -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");