Frame buffer module of python
Asked Answered
R

1

7

I'm looking for a python module which can display jpg or png file to /dev/fb0 directly.

I hope the the module can call and display the picture on screen by like this:

show_photo(path_to_jpg, x, y, dev='/dev/fb0')

I had searched such kind of python module on google for several days, and I found the link: [Module] Python Frame Buffer, but the website was not found.

Now, I'm using C program and call by os.system() function, and it is too slow. Does there has a python module which can show the picture directly to frame buffer, and support static picture, marquee? It will be better if the module also support playing video file like mplayer.

Recipience answered 23/7, 2012 at 7:56 Comment(1)
fbi player followed by pkill fbi does what you want. Both would be external processes to launch. You say you write C and ask for python - not sure I understand, but I don't think python has anything for this out of the box.Finny
K
11

Maybe you may use pygame.

http://www.pygame.org/wiki/about

Pygame uses either opengl, directx, windib, X11, linux frame buffer, and many other different backends...

UPDATE: Simple example:

import pygame
import sys
import time

pygame.init()

size = (pygame.display.Info().current_w, pygame.display.Info().current_h)
black = 0, 0, 0

screen = pygame.display.set_mode(size)

ball = pygame.image.load("ball.gif")
ballrect = ball.get_rect()

screen.fill(black)
screen.blit(ball, ballrect)
pygame.display.flip()

time.sleep(5)

Run:

SDL_NOMOUSE=1 python ./ball.py
Kienan answered 23/7, 2012 at 8:6 Comment(4)
Yes, I did find pygame, but I just need the simple function to show picture to frame buffer. And there has a lot of tutorial about pygame to draw pixel, but I only need to show picture static or like marquee. Do you have some idea about this?Recipience
Thanks for your example. I got an error on open /dev/snd/seq failed, and I think you can add sudo modprobe snd-seq-midi at first to avoid it. and the script need to run as root, or it will get an error pygame.error: video system not initialized.Recipience
Probably, your user should be added to 'video' and 'audio' groups.Kienan
Actually, I need the program to run once, exit and leave the image on screen. pygame will clear the screen after exit; if you want to show the image, pygame need to run background. So it's not fit my need. Anyway, thanks for your example !!Recipience

© 2022 - 2024 — McMap. All rights reserved.