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
This commit is contained in:
Sjoerd Simons 2014-12-08 11:47:12 +01:00 committed by Ray Strode
parent 61a26f4216
commit c052d9fccd

View file

@ -99,10 +99,13 @@ transform_to_argb32 (png_struct *png,
blue = data[i + 2]; blue = data[i + 2];
alpha = data[i + 3]; alpha = data[i + 3];
red = (uint8_t) CLAMP (((red / 255.0) * (alpha / 255.0)) * 255.0, 0, 255.0); /* pre-multiply the alpha if there's translucency */
green = (uint8_t) CLAMP (((green / 255.0) * (alpha / 255.0)) * 255.0, if (alpha != 0xff) {
0, 255.0); red = (uint8_t) CLAMP (((red / 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); 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); pixel_value = (alpha << 24) | (red << 16) | (green << 8) | (blue << 0);
memcpy (data + i, &pixel_value, sizeof(uint32_t)); memcpy (data + i, &pixel_value, sizeof(uint32_t));