【问题标题】:Pygame loads glitched versions of the original imagesPygame 加载原始图像的故障版本
【发布时间】:2023-03-25 17:30:01
【问题描述】:

你好 Stacked Overflow 社区!!

我一直是这个社区的浏览器,但我是第一次发帖。 我发帖只是因为我也很绝望。当我在 pygame 中导入图像时,某些图像会变得无法修复。我使用内置的 pygame.image.load(filename) 导入图像,奇怪的灰度图像是 JPG,而奇怪的像素化图像是 PNG。除非我试图修复错误,否则我不会以任何有意义的方式转换图片。我将在下面提供相关代码。非常感谢您提前提供的帮助,这意味着很多

class Alarm(MySprite):  

def __init__(self,image,x,y,radius,boundaries = None):
    MySprite.__init__(self,image,x,y)

    self.radius = radius

----------

def draw(self,screen):
    MySprite.draw(self,screen)


self.fireAlarmImage = pygame.image.load("fireAlarm.png")

if self.editing:
            self.background = Background(
                            "editing_background%d.jpg"%(self.level), True)

def set_background(self, picture = None):
    if picture:
        self.background = pygame.image.load(picture).convert_alpha()

Weird Perspective/Greyscale/ParticiallyDuplicated/Shifted Pygame Version

Original Image

【问题讨论】:

  • 我有更多错误的图像截图,但由于没有足够的声誉而无法发布。如果您有兴趣帮助我,请pm我以查看更多信息
  • 更新:尝试使用来自http://stackoverflow.com/questions/35384036/pygame-png-image-looks-corrupt/35385411的方法但是,如果我尝试按照它所说的去做评论,我得到“pygame.error:文件不是 Windows BMP 文件”

标签: python pygame


【解决方案1】:

我通过卸载 python 和 pygame 并重新安装来修复此错误。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-03-06
    • 1970-01-01
    • 2020-05-03
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多