Stannieman
Posts: 3
Joined: Mon Aug 29, 2016 6:16 pm

Picamera setting alpha for overlays not working

Sat Nov 09, 2019 2:11 pm

Hi

I'm using Picamera 1.13 and have a UI made of overlays. According the documentation it should be possible to change the layer and alpha to hide and show overlays.
Changing the layer works perfectly fine, but setting alpha to 0 on the same overlay does nothing. It does seem to work fine if I try to make a minimal repro, which is strange. But in my app it stays visible. When I print the alpha value I can see it's 0, yet it's fully opaque.

Has anyone encountered a similar issue before or are there known issues related to setting alpha?

Regards
Stan

6by9
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 7420
Joined: Wed Dec 04, 2013 11:27 am
Location: ZZ9 Plural Z Alpha, aka just outside Cambridge.

Re: Picamera setting alpha for overlays not working

Sun Nov 10, 2019 4:07 pm

What format are you passing for your overlay? RGB, or RGBA?
Previously formats that supported per pixel alpha didn't take global alpha, but there is an option to apply both of them. I suspect that PiCamera may not be setting that further flag.
Software Engineer at Raspberry Pi Trading. Views expressed are still personal views.
I'm not interested in doing contracts for bespoke functionality - please don't ask.

Stannieman
Posts: 3
Joined: Mon Aug 29, 2016 6:16 pm

Re: Picamera setting alpha for overlays not working

Mon Nov 11, 2019 1:34 pm

Good point. My overlays are indeed RGBA. I'll try with RGB ones later this week and let you know if they do work fine.
Moving layers around would work fine for my application BTW (though a bit less convenient), just found it curious that alpha was not working.

6by9
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 7420
Joined: Wed Dec 04, 2013 11:27 am
Location: ZZ9 Plural Z Alpha, aka just outside Cambridge.

Re: Picamera setting alpha for overlays not working

Mon Nov 11, 2019 1:50 pm

If setting it from the MMAL layer then you want to add the MMAL_DISPLAY_ALPHA_FLAGS_MIX flag to the alpha value.

If PiCamera is just passing the value through, then you may be able to set the alpha to your desired level + (1<<31) (2147483648 decimal). I suspect it won't work due to https://github.com/waveform80/picamera/ ... rs.py#L116 checking the range for your alpha parameter.
Software Engineer at Raspberry Pi Trading. Views expressed are still personal views.
I'm not interested in doing contracts for bespoke functionality - please don't ask.

Return to “Camera board”