From 493c5842a1a4fc966b3cf07fa20032a340712b73 Mon Sep 17 00:00:00 2001 From: Rogier Date: Thu, 8 May 2014 14:21:58 +0200 Subject: [PATCH] Fix conversion of libgd alpha value: libgd uses 0..127 (not 255) --- Color.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Color.h b/Color.h index 22bdbc5..02cf999 100644 --- a/Color.h +++ b/Color.h @@ -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;