问题描述
我正在寻找一个可以直接显示jpg或png文件的python模块.
我希望该模块可以通过这样的方式在屏幕上拨打并显示图片:
show_photo(path_to_jpg, x, y, dev='/dev/fb0')
我已经在Google上搜索了这种python模块几天,我找到了链接: [模块] python框架缓冲区,但找不到网站.
现在,我正在使用C程序并通过os.system()函数来调用,并且它太慢了.是否有一个Python模块可以直接显示图片以框架缓冲区,并支持静态图片,Marquee?如果模块还支持播放视频文件,例如mplayer.
,将会更好推荐答案
也许您可以使用pygame.
http://www.pygame.org/wiki/wiki/about/about
pygame使用OpenGL,DirectX,Windib,X11, Linux框架缓冲区, 还有许多其他不同的后端...
更新: 简单示例:
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)
运行:
SDL_NOMOUSE=1 python ./ball.py
问题描述
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.
推荐答案
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