【问题标题】:Frame buffer module of pythonpython的帧缓冲模块
【发布时间】:2012-07-23 07:56:57
【问题描述】:

我正在寻找可以将jpg 或png 文件直接显示到/dev/fb0 的python 模块。

我希望模块可以这样调用并在屏幕上显示图片:

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

我在google上搜索了几天这样的python模块,找到了链接:[Module] Python Frame Buffer,但是没有找到网站。

现在,我正在使用 C 程序并通过 os.system() 函数调用,它太慢了。是否有python模块可以直接将图片显示到帧缓冲区,并支持静态图片,选框?如果模块也支持播放mplayer等视频文件就更好了。

【问题讨论】:

    标签: python framebuffer


    【解决方案1】:

    也许你可以使用 pygame。

    http://www.pygame.org/wiki/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
    

    【讨论】:

    • 是的,我确实找到了pygame,但我只需要简单的功能即可将图片显示到帧缓冲区。并且有很多关于pygame 绘制像素的教程,但我只需要显示图片静态或类似选框。你对此有什么想法吗?
    • 感谢您的示例。我在open /dev/snd/seq failed 上遇到错误,我认为您可以先添加sudo modprobe snd-seq-midi 以避免它。并且脚本需要以root身份运行,否则会报错pygame.error: video system not initialized。
    • 您的用户可能应该被添加到“视频”和“音频”组中。
    • 实际上,我需要程序运行一次,退出并将图像留在屏幕上。 pygame 会在退出后清屏;如果要显示图像,pygame 需要运行后台。所以不符合我的需要。无论如何,谢谢你的榜样!!
    猜你喜欢
    • 1970-01-01
    • 2011-12-06
    • 2011-02-22
    • 2013-02-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-01-31
    • 2023-03-07
    相关资源
    最近更新 更多