[Pixman] How to modify image opacity?

Søren Sandmann soren.sandmann at gmail.com
Sat Aug 22 21:52:03 PDT 2015

Most likely what happened is that pixman_image_create_bits() returned NULL
because the stride (not the width) was not divisible by 4 (such images are
not supported by pixman). If you then used this NULL pointer as the mask in
a pixman_image_composite() operation, it would indeed look like the mask
was completely ignored.

Using a mask is the right way to change the alpha value for an image. It's
best to use a mask created with pixman_image_create_solid() because that
will be more likely to hit various optimized routines. (You can also use an
mask that is 1x1 and has repeat set to hit those routines, but using
create_solid() is recommended).

[Sorry about the duplicate -- I forgot to copy the list on the first mail]


On Sat, Aug 22, 2015 at 4:38 PM, Jonathan Meson <jona at visualblasters.com>

> Ah, never mind I resolved this by using a mask!
> I did notice a particular bug with using a PIXMAN_a8  mask on images of
> sizes not divisible by 4 such as a width 854.  The alpha of the mask was
> completely ignored. I was using composite with PIXMAN_OP_OVER and running
> an arm build neon disabled.
> On Fri, Aug 21, 2015 at 11:39 AM, Jonathan Meson <jona at visualblasters.com>
> wrote:
>> Hey guys, I'm new to the list. I'm very excited about this powerful
>> library and slowly understanding how to use it properly.
>> So, I'm looking to modify the opacity of an image but I'm not sure how. I
>> attempted to do some research and try some things but it was a bit hard
>> finding documentation or samples.
>> The simple formula to set opacity at 50% is:
>> float alpha = 0.5f;
>> C = c*alpha;
>> A = a*alpha;
>> However, I'm not sure how to achieve this using pixman_image_composite or
>> any other method from the pixman library.
>> Thanks for any details or guidance with respect to this.
>> --
>> *Jonathan Meson*
>> *CEO and Lead Engineer*
>> Visual Blasters LLC
>> 717-813-4287
> --
> *Jonathan Meson*
> *CEO and Lead Engineer*
> Visual Blasters LLC
> 717-813-4287
> _______________________________________________
> Pixman mailing list
> Pixman at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/pixman
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/pixman/attachments/20150823/b681f03f/attachment.html>

More information about the Pixman mailing list