Using Interstate 75, can I use graphics with alpha channel?

I like to display a 64x64 PNG image that has an alpha channel (partial transparency), which I like to draw over a code-generated (animated) graphics.

It appears that the `pngdec`'s code for drawing PNG files over a `PicoGraphics` object does not support alpha channels in the way that, if the alpha value is 50%, it should mix the existing pixel with the pixel color from the image half-and-half. Instead, it draws the image pixel completely over the pixel, ignoring what’s been there before.

Is there any way to get this working in MicroPython? One major issue appears to be that `PicoGraphics` doesn’t even offer a function to read the RGB value of a pixel. So I would have to first draw my generated image into a buffer that supports reading pixel, then draw the png image over that (with a alpha channel handling), and then draw the final image into the Hub75 display buffer.

Anyone know how to accomplish that? I mean, are there other graphics libs that would work on the Pico W for this purpose?

PicoGraphics is a highly efficient, but primitive implementation of a set of graphics routines. It has a “canvas”, and every operation draws on that canvas. Therefore, you don’t e.g. have a line with a color as an attribute which you could potentially move around, but instead you draw a line with the currently selected color and then it is on the canvas.

So with this basic philosophy, transparancy does not work. You could try to switch to CircuitPython, which has a much more sophisticated graphics system, but expect to spend some time learning about it. The good news is that there are many guides available. The bad news is that the graphics system is slower and needs much more memory.

If you want to stick with MicroPython, have a look at LVGL which is very commonly used in embedded projects. No idea if this supports transparency, but there are many docs so it should be easy to find out. MicroPython has LVGL bindings, but you will probably have to switch to a more mainline MicroPython dialect.

1 Like