[Pixman] How to modify image opacity?

Jonathan Meson jona at visualblasters.com
Sun Aug 23 10:08:17 PDT 2015


I appreciate your response.

I did notice that using a mask of type PIXMAN_a8r8g8b8 resolved the issue
for these none divisible by 4 widths. However, I do like your suggestion
which is much better! :)

Just to make sure I'm using pixman_color_t correctly. Does pixman_color_t
need to be premultiplied? AFAIK it seems to work fine using straight alpha
such as the example below. Also, the color channels need to be 16bit?

pixman_color_t maskPixel    = {0xffff, 0xffff, 0xffff, 0xffff*aAlpha };
mask_image = pixman_image_create_solid_fill(&maskPixel);

Thanks
- Jona

On Sun, Aug 23, 2015 at 12:52 AM, Søren Sandmann <soren.sandmann at gmail.com>
wrote:

> 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]
>
> Søren
>
> On Sat, Aug 22, 2015 at 4:38 PM, Jonathan Meson <jona at visualblasters.com>
> wrote:
>
>> 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
>>
>>
>


-- 
*Jonathan Meson*
*CEO and Lead Engineer*
Visual Blasters LLC
717-813-4287
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/pixman/attachments/20150823/8ca35d6c/attachment-0001.html>


More information about the Pixman mailing list