mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 21:27:34 +00:00
LibGfx: Fix parsing of rgba values
Trim whitespace of the alpha component before calling parse_first_floating_point, which doesn't handle it.
This commit is contained in:
parent
1bbfe4630d
commit
0ad131e13d
1 changed files with 3 additions and 2 deletions
|
@ -64,8 +64,9 @@ static Optional<Color> parse_rgba_color(StringView string)
|
||||||
auto b = parts[2].to_int().value_or(256);
|
auto b = parts[2].to_int().value_or(256);
|
||||||
|
|
||||||
double alpha = 0;
|
double alpha = 0;
|
||||||
char const* start = parts[3].characters_without_null_termination();
|
auto alpha_str = parts[3].trim_whitespace();
|
||||||
auto alpha_result = parse_first_floating_point(start, start + parts[3].length());
|
char const* start = alpha_str.characters_without_null_termination();
|
||||||
|
auto alpha_result = parse_first_floating_point(start, start + alpha_str.length());
|
||||||
if (alpha_result.parsed_value())
|
if (alpha_result.parsed_value())
|
||||||
alpha = alpha_result.value;
|
alpha = alpha_result.value;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue