[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 21:38, Josh Segall wrote:
> 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?
>

You've probably already found this, but for the record:

"""
set_grab
pygame.event.set_grab(bool) -> None

Grabs all mouse and keyboard input for the display. Grabbing the input is not 
neccessary to receive keyboard and mouse events, but it ensures all input 
will go to your application. It also keeps the mouse locked inside your 
window. Set the grabbing on or off with the boolean argument. It is best to 
not always grab the input, since it prevents the end user from doing anything 
else on their system.
"""

cheers,
John.

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