【问题标题】:pygame with FULLSCREEN flag renders content scaled带有FULLSCREEN标志的pygame渲染内容缩放
【发布时间】:2017-07-08 22:08:48
【问题描述】:

我在树莓派上使用 pygame。 相同的代码过去在 800x600 时覆盖全屏,现在在 1280x720 时不会覆盖,也不是过/欠扫描:

Pygame 示例输出:

通过 omxplayer 播放视频:

pygame 示例图片中的所有代码只是问题的演示:

import pygame
import time
pygame.display.init()
pygame.font.init()
screen = pygame.display.set_mode((1280, 720)) #, pygame.FULLSCREEN)
screen.fill((255, 0, 0))
pygame.display.flip()
time.sleep(45)

【问题讨论】:

    标签: python raspberry-pi pygame


    【解决方案1】:

    您可以使用list_modes 函数返回可用全屏分辨率列表:

    modes = pygame.display.list_modes()
    if modes: # check if the list is not empty
        screen = pygame.display.set_mode(modes[0], pygame.FULLSCREEN) # use the first one
    else:
        screen = pygame.display.set_mode((800, 600)) # use a default resolution
    

    注意:如果您在 Windows 上遇到高 DPI 缩放问题(例如,您的显示器的一部分不可见),您可以使用此代码来修复它们:

    import ctypes
    ctypes.windll.shcore.SetProcessDpiAwareness(1)
    

    【讨论】:

      猜你喜欢
      • 2018-09-30
      • 1970-01-01
      • 1970-01-01
      • 2018-06-01
      • 2013-05-06
      • 2021-04-19
      • 2012-12-17
      • 1970-01-01
      相关资源
      最近更新 更多