python - 在pygame中禁用抗锯齿
问题描述
我试图在 pygame 中设置单个像素pygame.PixelArray
。不幸的是,看起来 pygame 会自动对这些像素进行抗锯齿处理。这是我到目前为止所尝试的:
import pygame
BLACK = (0, 0, 0)
BLUE = (0, 0, 255)
WHITE = (255,255,255)
class GUI:
def __init__(self):
self.screen = pygame.display.set_mode((300, 300))
pygame.mouse.set_visible(True)
self.clock = pygame.time.Clock()
def gameloop(self):
running = True
while running:
self.screen.fill(WHITE)
# event handling
for event in pygame.event.get():
if event.type == pygame.QUIT:
running = False
# drawing
# for some reason, everything gets anti-aliased
pixel_array = pygame.PixelArray(self.screen)
pixel_array[100][100] = BLACK
pixel_array[100][101] = BLUE
pixel_array[101][100] = BLUE
pixel_array[101][101] = BLACK
del pixel_array
# update full display
pygame.display.flip()
self.clock.tick(30)
def main():
pygame.init()
gui = GUI()
gui.gameloop()
pygame.quit()
if __name__ == '__main__':
main()
我得到了什么:
我期望得到的:
系统:
Python 版本:3.7.2(64 位)
操作系统:Windows 10 Home 版本 1803 Build 17134.590
pygame 版本:1.9.4
显示:集成在 Lenovo-Laptop (1920 x 1080)
处理器:Intel-Core-i5-6300HQ
IGP:Intel高清显卡 530
GPU:Nvidia GeForce GTX 960M
解决方案
在Eric的提示后,我发现问题不是由 pygame 引起的,而是由显示分辨率设置引起的。默认情况下,显示比例为 125%。
由于我的 Windows 设置为德语,所以我不知道如何用英语描述这些设置在哪里可以找到,所以我制作了屏幕截图:
推荐阅读
- python - 将第二个副本中的值移动到第一个副本
- google-forms - 将 Google 表单限制为 2 种类型的电子邮件
- reactjs - 在 SSR 上反应水合
- c++ - URLDownloadToFile 函数在 Windows XP 上返回 INET_E_DOWNLOAD_FAILURE
- javascript - 如何将javascript表格放入谷歌表格?
- c# - 24 位彩色 Ansi Win32 获取屏幕缓冲区位置的背景属性和字符
- deep-learning - 运行零镜头模型时错误说明缺少标记器
- c# - 如何将时间戳值参数从 C# 传递到 SQL
- regex - 查找超过四位数的词
- html - 无法从 mysql 检索数据到 django 中的 html 模板(PyCharm)