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
commit 10757b7787
Notes: sideshowbarker 2024-07-17 04:10:16 +09:00

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