From: Sjoerd Simons Date: Mon, 8 Dec 2014 10:47:12 +0000 (+0100) Subject: ply-image: Don't do alpha pre-multiplication for opaque pixels X-Git-Tag: 0.9.3~63 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c052d9fccdc790e7bcd9a37c0efa99855ad55653;p=thirdparty%2Fplymouth.git ply-image: Don't do alpha pre-multiplication for opaque pixels When transforming the output of libpng to ARG32 with pre-multiplied alpha, only do the multiplications if the pixel isn't opaque. Otherwise plymouth is just applying a very complicated identity function. https://bugs.freedesktop.org/show_bug.cgi?id=87105 --- diff --git a/src/libply-splash-graphics/ply-image.c b/src/libply-splash-graphics/ply-image.c index f838601a..8b469788 100644 --- a/src/libply-splash-graphics/ply-image.c +++ b/src/libply-splash-graphics/ply-image.c @@ -99,10 +99,13 @@ transform_to_argb32 (png_struct *png, blue = data[i + 2]; alpha = data[i + 3]; - red = (uint8_t) CLAMP (((red / 255.0) * (alpha / 255.0)) * 255.0, 0, 255.0); - green = (uint8_t) CLAMP (((green / 255.0) * (alpha / 255.0)) * 255.0, - 0, 255.0); - blue = (uint8_t) CLAMP (((blue / 255.0) * (alpha / 255.0)) * 255.0, 0, 255.0); + /* pre-multiply the alpha if there's translucency */ + if (alpha != 0xff) { + red = (uint8_t) CLAMP (((red / 255.0) * (alpha / 255.0)) * 255.0, 0, 255.0); + green = (uint8_t) CLAMP (((green / 255.0) * (alpha / 255.0)) * 255.0, + 0, 255.0); + blue = (uint8_t) CLAMP (((blue / 255.0) * (alpha / 255.0)) * 255.0, 0, 255.0); + } pixel_value = (alpha << 24) | (red << 16) | (green << 8) | (blue << 0); memcpy (data + i, &pixel_value, sizeof(uint32_t));