Fix conversion of libgd alpha value: libgd uses 0..127 (not 255)

master
Rogier 2014-05-08 14:21:58 +02:00
parent 1c7b31a5dc
commit 493c5842a1
1 changed files with 2 additions and 2 deletions

View File

@ -12,8 +12,8 @@ struct Color {
Color(const std::string &s, int alpha = 1);
Color &operator=(const Color &c);
unsigned to_uint() const { return (unsigned(a) << 24) + (unsigned(r) << 16) + (unsigned(g) << 8) + unsigned(b); }
//libgd treats 255 as transparent, and 0 as opaque ...
int to_libgd() const { return ((0xff - int(a)) << 24) + (int(r) << 16) + (int(g) << 8) + int(b); }
//libgd treats 127 as transparent, and 0 as opaque ...
int to_libgd() const { return (((0xff - int(a)) >> 1) << 24) + (int(r) << 16) + (int(g) << 8) + int(b); }
uint8_t r;
uint8_t g;
uint8_t b;