I'm trying to load a transparent image into pygame using the following code:
def load_image(name, colorkey=None):
fullname = os.path.join('data', name)
try:
image = pygame.image.load(fullname)
except pygame.error, message:
print 'Cannot load image:', fullname
raise SystemExit, message
image = image.convert()
if colorkey is not None:
if colorkey is -1:
colorkey = image.get_at((0,0))
image.set_colorkey(colorkey, RLEACCEL)
return image, image.get_rect()
For some reason, everytime I load the image the background is automatically changed to black? I'm not using the colorkey in this case as my image(s) will end up with a white border around them which is quite visible given that my game's background is constantly changing.
Any ideas?
Thanks,Regards