【发布时间】:2016-09-28 05:47:33
【问题描述】:
当尝试通过 Pygames 图像加载功能加载图像时,加载的图像顶部会出现一个黑条。切片瓷砖时,很明显该条将内容偏移了 1 像素。
尝试各种文件格式(gif、png、alpha、非 alpha 等)与偏移量有类似的效果,但值得注意的是 png 在使用 convert_alpha 时会偏移除 alpha 之外的所有内容。
Example of the offest, and random colours when split into tiles 和 the tileset image being used。
即使是整个图像的简单 blit 也存在相同的问题:
import pygame
import pygame.locals
pygame.init()
screen = pygame.display.set_mode((128, 128))
screen.fill((255,255,255))
screen.blit(pygame.image.load("src/tiles.gif"), (16,16))
pygame.display.flip()
我也尝试过使用convert() 和convert_alpha(),效果相似。
感谢任何帮助。我在 OS X 10.11 上的 Python 3.5 中运行 Pygame 1.9.1。
编辑:我已经在视网膜和非视网膜显示器上测试过,两者都是一样的。当使用 alpha 时,看起来只有 rgb 值向下移动了 1px,而 alpha 保持在原位。
【问题讨论】:
标签: python image python-3.x pygame