Skip to content

Commit

Permalink
Fix color2int, int2color alpha handling (libgd alpha is 0-127)
Browse files Browse the repository at this point in the history
  • Loading branch information
Martijn Versteegh authored and sfan5 committed Nov 22, 2018
1 parent 97c5dc0 commit f7b0d5c
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Image.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

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

Expand All @@ -31,7 +31,7 @@ static inline Color int2color(int c)
c2.g = (c >> 8) & 0xff;
c2.r = (c >> 16) & 0xff;
a = (c >> 24) & 0xff;
c2.a = 255 - a;
c2.a = 255 - (a*255 / gdAlphaMax);
return c2;
}

Expand Down

0 comments on commit f7b0d5c

Please sign in to comment.