Pygame 窗口大小错误

问题描述 投票:0回答:1

当我运行此代码时:

import pygame
SCREEN = pygame.display.set_mode((0,0),pygame.FULLSCREEN)
img = pygame.image.load("Untitled.png")
run = True
while run:
    for _ in pygame.event.get():
        if _.type == pygame.QUIT:
            run = False
        SCREEN.blit(img,(0,0))
        pygame.display.update()
pygame.quit()

其中 img 是 1920x1080 图像,屏幕尺寸在我的屏幕上显示为更像 1200x675。

这是一台新电脑,但如果我运行

pygame.display.Info()
,它显示我的显示器尺寸为1920x1080,而在Windows显示设置中,它是1920x1080。

python pygame size screen
1个回答
0
投票

这是因为您的系统缩放了窗口大小。如何摆脱它取决于操作系统。例如,在 Windows 系统上,您可以使用

SetProcessDPIAware
将进程默认 DPI 感知设置为系统 DPI 感知

import ctypes

ctypes.windll.user32.SetProcessDPIAware(True)
© www.soinside.com 2019 - 2024. All rights reserved.