[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [pygame] Problem loading TGA images from StringIO



On Monday 05 April 2004 20:05, Nicolás Sanguinetti wrote:
> I'm not too familiarized with pyGame support for different image formats.
> But maybe it just doesn't support TGA... =)
>
> Nicolas

Hi,

take a look at the Pygame documentation for pygame.image.load():

"""
load 
pygame.image.load(file, [namehint]) -> Surface 
This will load an image into a new surface. You can pass it either a filename, 
or a python file-like object to load the image from. If you pass a file-like 
object that isn't actually a file (like the StringIO class), then you might 
want to also pass either the filename or extension as the namehint string. 
The namehint can help the loader determine the filetype. 

If pygame was installed without SDL_image support, the load will only work 
with BMP images. You can test if SDL_image is available with the 
get_extended() function. These extended file formats usually include GIF, 
PNG, JPG, PCX, TGA, and more. 
 
If the image format supports colorkeys and pixel alphas, the load() function 
will properly load and configure these types of transparency. 
"""

I've not tested it, but this suggests that you need to pass a namehint string. 
Something like 'tga' or '.tga' might work,

cheers,
John.