[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [pygame] Determining whether a Pixel in a Sprite is Transparent?



Steven M. Castellotti wrote:
> Can you tell if it sounds like I'm doing something wrong, or if there's
> another format/setting I should save my images in? 

sounds like your problem is that the images still don't really have 
a colorkey set. i've found that gimp really sucks at 8bit images and 
especially 8bit images with colorkey.

you'll need to make sure your image is "indexed" color, but make 
sure it's using less than 256 colors (i believe it defaults to 255).
then in the actual gimp window you'll need to make the colorkeyed 
areas of the image actually transparent. this seems to involve a bit 
of fenagling like adding dummy layers, cutting out areas and finally 
flattening them all again. of course do this all last, since most of 
gimp's tools don't work well with the transparent areas.

after calling pygame.image.load() you can test if the image really 
has a colorkey by calling img.get_colorkey(). if it returns None 
there is no key. you can set one easily by passing the correct 
color, img.set_colorkey((0, 0, 0)) would work in your case.

a common trick is to just pull the color at some corner pixel and 
assume that should be the colorkey..
img.set_colorkey(img.get_at((0, 0)))



____________________________________
pygame mailing list
pygame-users@seul.org
http://pygame.seul.org