What's the best way to have an image as a background ?

89 views
Skip to first unread message

Stuart Axon

unread,
Dec 20, 2016, 8:10:32 PM12/20/16
to pi3d
Is there a better way than just making a big image sprite ?

Paddy

unread,
Dec 21, 2016, 4:37:39 AM12/21/16
to pi3d
I can't really think of many other way.  On the raspberry pi you could save a bit of processing by having the background drawn by another process (you could use pi3d with multiprocessing,  search on raspberrpi.org forum large screen problem) Then make the foreground pi3d background 0.0 alpha. 
 ?

Paddy

unread,
Dec 21, 2016, 6:47:20 AM12/21/16
to pi3d
pi3d in two processes here: https://www.raspberrypi.org/forums/viewtopic.php?p=1056401#p1056401 In the background process you would need to set the Display.create(... layer=-1)  (I think -ve is behind, otherwise try other way round!) If you didn't want to change the background image you could simply make the background process wait for a quit signal to be queued from the foreground process. If you wanted to be able to change the background you could wait for instructions in the queue in the same way, the main thing would be to not keep redrawing the background. An alternative, possibly simpler, way would be to subprocess.call() a simple image display program that would appear behind the pi3d display surface (or maybe use Tk or pygame

However, I'm not sure how much CPU or GPU time is spent re-drawing the background every frame. What is the specific problem you are having? 

Stuart Axon

unread,
Dec 21, 2016, 7:14:46 AM12/21/16
to pi3d
No problem,  just wanted to know if this was the correct way of doing things :)

The two process thing is really useful as I will need to do exactly that (I am going to use pi3d as a sort of overlay on top of videos that are playing underneath).

Paddy

unread,
Dec 22, 2016, 4:20:24 PM12/22/16
to pi3d
Stuart, I don't know what you are going to use for rendering the video but if it's a completely independent program such as omxplayer then you are probably better to use subprocess rather than multiprocessing. Worth looking at @swehner's project as he played video underneath pi3d rendering (but rather complicated)

Stuart Axon

unread,
Feb 15, 2017, 6:30:10 AM2/15/17
to pi3d
In the end I went with this, with the pi3d stuff as a separate program + layer on top.

A handy side effect is that if I need to restart the program underneath I just make sure the top one is displayed during that time.

The only bit of finenessing needed, was to make sure that when I make the top program completely transparent that I have a sleep() in the main loop to free up resources.
Reply all
Reply to author
Forward
0 new messages