Why does pygame icon change color?

Viewed 98

I'm making a Minesweeper in pygame but when I set the icon it changes the color. The icon that I get is bluer than the expected icon and I don't understand why. Here's the code that I use:

Actual Icon actual icon

Expected Icon expected icon

import pygame as pg

pg.init()
window = pg.display.set_mode(size)

icon = pg.image.load("icon.png")
pg.display.set_icon(icon)
pg.display.set_caption("Minesweeper")

I tried to use icon = pg.image.load("icon.png").convert() and icon = pg.image.load("icon.png").convert_alpha() but it doesn't work.

Do you know why it does this and how to fix it?

1 Answers

It looks like your PNG file has some embedded information or formatting that is causing this distortion. I saved the image as a bitmap bitmap icon using paint.net and it displays without modification:

enter image description here

Perhaps some conversion commands could transform your image as desired, but it's probably easier to do the image manipulation outside of pygame.

Related