diff options
author | Andrea Canciani <ranma42@gmail.com> | 2011-02-18 00:07:21 +0100 |
---|---|---|
committer | Andrea Canciani <ranma42@gmail.com> | 2011-02-18 00:13:56 +0100 |
commit | 97b7b2dcb43fca0535fc674a916437174f257629 (patch) | |
tree | 6d3f6da0cb7d5f48eec7c7b57768d9cfc8501d39 | |
parent | 6261821e813bc106300cd079117c8a7777863a28 (diff) |
solid: fix premultiplication
-rw-r--r-- | pixman/pixman-solid-fill.c | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/pixman/pixman-solid-fill.c b/pixman/pixman-solid-fill.c index 3d314bf..71d495c 100644 --- a/pixman/pixman-solid-fill.c +++ b/pixman/pixman-solid-fill.c @@ -59,10 +59,19 @@ pixman_image_create_solid_fill (pixman_color_t *color) { double components[4]; - components[0] = (1. / 65535.) * color->alpha; - components[1] = (1. / 65535.) * color->red; - components[2] = (1. / 65535.) * color->green; - components[3] = (1. / 65535.) * color->blue; + if (color->alpha != 0) { + double inv = 1. / color->alpha; + + components[0] = color->alpha / 65535.; + components[1] = inv * color->red; + components[2] = inv * color->green; + components[3] = inv * color->blue; + } else { + components[0] = 0; + components[1] = 0; + components[2] = 0; + components[3] = 0; + } return pixman_image_create_solid_fill_cs (&_pixman_color_space_device_rgb, components); } @@ -80,8 +89,9 @@ pixman_image_create_solid_fill_cs (pixman_color_space_t *color_space, img->type = SOLID; - for (i = 0; i < n_comp; i++) - img->solid.components[i] = components[i]; + img->solid.components[0] = components[0]; + for (i = 1; i < n_comp; i++) + img->solid.components[i] = components[0] * components[i]; img->common.color_space = pixman_color_space_ref (color_space); img->common.classify = solid_fill_classify; |