0
votes

I'm having some issues loading an image into pygame. I've searched through here and google and tried using os.path.join and just the full path. Nothing is working. The error I'm getting is: libpng error: bad adaptive filter value. Here is my code for trying to load in the image.

background = pygame.image.load("background/level1.png")
background_rect = background.get_rect()

Any idea what I'm doing wrong? I've also tried the following:

background = pygame.image.load(os.path.join("background","level1.png"))
background_rect = background.get_rect()
background = pygame.image.load("L:\\Spring 2014\\CSC177\\The End\\The End\\background\\level1.png")
background_rect = background.get_rect()
2
What does pygame.image.get_extended() return? - Drewness
Try with another png file. The error suggests that there is something wrong with the file, not that you are passing it the file location incorrectly. - Michael Brennan
It is now working with jpg files. Thanks everyone. - jefpadfi

2 Answers

1
votes

Ok so What I'm getting from this is you don't have the full PIL installed completely so try converting the image to a .gif which I believe is your problem. It is getting to the .png file, but it can't load it because you don't have the full PIL support in your python. So like I said I would convert the png to a gif file and try it again.

1
votes

I don't think that the path is the issue here.. As long as the os command

os.path.exists(path) 

evaluates to True when you supply the image's path, pygame should be able to find it. If I were you I would try to open an image with another format or in the worst case scenario reinstall pygame

Hope tha helped! Cheers, Alex