mirror of
https://gitlab.freedesktop.org/plymouth/plymouth.git
synced 2026-05-08 13:38:45 +02:00
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:
parent
61a26f4216
commit
c052d9fccd
1 changed files with 7 additions and 4 deletions
|
|
@ -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];
|
||||||
|
|
||||||
|
/* 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);
|
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,
|
green = (uint8_t) CLAMP (((green / 255.0) * (alpha / 255.0)) * 255.0,
|
||||||
0, 255.0);
|
0, 255.0);
|
||||||
blue = (uint8_t) CLAMP (((blue / 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));
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue