This is a warning issued by libpng
. It means that the PNG
image file you are using has chunks iCCP invalid .
To remove invalid chunks from a PNG
image, you can use the convert
of the ImageMagick
library by passing the -strip
at the command line:
$ convert icone.png -strip icone_ok.png
Assuming you have an image file, in PNG
format, with dimensions of 400x400
, called icone.png
:
Hereisaprogramthatcanloadtheaboveimageusingthepygame.image.load()
functionandthenuseitasthewindowiconcreatedbymeansofthepygame.display.set_icon()
functionwithoutanykindoferrororwarning:
importsysimportpygamepygame.init()icon=pygame.image.load('icone.png')screen=pygame.display.set_mode((500,500))pygame.display.set_caption('FooBar')pygame.display.set_icon(icon)screen.blit(icon,(50,50))clk=pygame.time.Clock()running=True;whilerunning:foreventinpygame.event.get():ifevent.type==pygame.QUIT:running=False;pygame.display.update()clk.tick(25);pygame.quit()sys.exit()
ExamplebeingtestedonaworkspaceLinux/GNOME
: