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

Re: [pygame] Problem loading TGA images from StringIO



Thanks, it was the namehint after all that fixed the problem.  I should 
have known, as I've run into that kind of problem before :)

For the record, TGAs are supported (at least on my config), and work 
rather well.  I had been using them successfully beforehand without having 
them in a zip.  I just ran into this problem when switching to a zip file.

On an unrelated note, anyone know how to trap the mouse cursor in the 
window in windowed (non-fullscreen) mode? 

Thanks for the help!
-Josh

On Mon, 5 Apr 2004, John Popplewell wrote:

> 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.
>