pimoroni-pico icon indicating copy to clipboard operation
pimoroni-pico copied to clipboard

png.decode is very slow on Stellar Unicorn / Pico W

Open phennessey opened this issue 1 year ago • 1 comments

I am using png.decode to cycle through areas of a tiny png file on a Stellar Unicorn (Pico W). This enables animation frames to be stacked in a single PNG, using "while True:" loop to display simple animations.

I'm not calling any other PNG functions inside the loop. It's just a single 10x200px PNG image, and I'm looping through a different 10x10px area of it as fast as possible:

# Looping f from 0 to 19 gives 20 frames of animation with one PNG strip
png.decode(6,0, source=(0, f * 10, 10, 10))

I can't seem to get better than 4-6 FPS with this method, even with 0 sleep time between loops. After trying everything I can think of to improve performance, I'm guessing this is as good as it's going to get (though admittedly I'm a bit of a novice in python). I was hoping that calling different areas of the same PNG over and over would not incur this many compute cycles, but it appears that every call of png.decode is quite costly. I thought this would be like a simple recalculation of a frame buffer, but maybe that's not how png.decode actually works.

If there is a workaround, I would love to know what I can do!

phennessey avatar Oct 27 '23 02:10 phennessey

hi im unsure if it helps but i've done a similar thing with pngs here

https://github.com/mrglennjones/Halloweenicorn

maybe it can help you?

mrglennjones avatar Nov 01 '23 09:11 mrglennjones