Skip to content

Commit f7b0d5c

Browse files
Martijn Versteeghsfan5
Martijn Versteegh
authored andcommittedNov 22, 2018
Fix color2int, int2color alpha handling (libgd alpha is 0-127)
1 parent 97c5dc0 commit f7b0d5c

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed
 

Diff for: ‎Image.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
static inline int color2int(Color c)
2121
{
22-
u8 a = 255 - c.a;
22+
u8 a = (255 - c.a) * gdAlphaMax / 255;
2323
return (a << 24) | (c.r << 16) | (c.g << 8) | c.b;
2424
}
2525

@@ -31,7 +31,7 @@ static inline Color int2color(int c)
3131
c2.g = (c >> 8) & 0xff;
3232
c2.r = (c >> 16) & 0xff;
3333
a = (c >> 24) & 0xff;
34-
c2.a = 255 - a;
34+
c2.a = 255 - (a*255 / gdAlphaMax);
3535
return c2;
3636
}
3737

0 commit comments

Comments
 (0)