0
\$\begingroup\$

On Python 3.2.5 32 bit, I installed pygame. I made some code with it. It included pygame.display.set_icon(image). The image file is .png and I loaded it by using image = pygame.image.load("clockico.png").convert_alpha() The transparent pixels on the .png file showed up as black. I tried using a .ico file instead of a .png file, but the output was the same. Is there a way to fix this?

\$\endgroup\$

2 Answers 2

0
\$\begingroup\$

You should change the convert_alpha() part to just convert(), as the convert_alpha() changes the transparent pixels.

\$\endgroup\$
0
\$\begingroup\$

On Windows 10, using Pygame 1.9.6, I have found that all I need to do is to scale my PNG image to match an allowed Windows icon size. For example, with my 80x80 image, I do:

icon = pygame.image.load(ICON_FILENAME)
icon = pygame.transform.smoothscale(icon, (96, 96))
pygame.display.set_icon(icon)

If you're only using the image as an icon (and not planning to reuse the image object), you do not need to call image.convert() or image.convert_alpha(). In fact, I would recommend setting your icon as early as possible, even before you call pygame.display.set_mode(), and convert() or convert_alpha() will fail if you call them that early.

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .