mirror of
https://github.com/thorvg/thorvg.git
synced 2025-06-14 12:04:29 +00:00
svg: fix opacity percentage value parsing
Percentage values wasn't handled by _toOpacity() function. Other incorrect values was handled wrongly. Now fixed.
This commit is contained in:
parent
f5f1e9f3a4
commit
ae3141d65c
1 changed files with 5 additions and 3 deletions
|
@ -163,11 +163,13 @@ static float _toOffset(const char* str)
|
|||
static int _toOpacity(const char* str)
|
||||
{
|
||||
char* end = nullptr;
|
||||
int a = 0;
|
||||
float opacity = svgUtilStrtof(str, &end);
|
||||
|
||||
if (end && (*end == '\0')) a = lrint(opacity * 255);
|
||||
return a;
|
||||
if (end) {
|
||||
if (end[0] == '%' && end[1] == '\0') return lrint(opacity * 2.55f);
|
||||
else if (*end == '\0') return lrint(opacity * 255);
|
||||
}
|
||||
return 255;
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue