On Tue, Dec 23, 2008 at 8:22 PM, Alex Holkner <[email protected]>wrote:
> > On 24/12/2008, at 11:07 AM, "Tristam MacDonald" <[email protected]> > wrote: > > Either this is not my day, or my install of pyglet is borked... Having > copied your example into a file and run it (from the correct location), I > get the following: > File "region.py", line 2, in <module> > i = pyglet.image.load('examples/programming_guide/kitten.jpg') > File "pyglet/image/__init__.py", line 194, in load > raise first_exception > pyglet.image.codecs.dds.DDSException: Invalid DDS file (incorrect header). > > Am I just being incredibly dense, or is something wrong my install? I don't > get why the DDS loader would be invoked for a jpg. > > > This is an unfortunate exception that actually means that none of the image > decoders were successful; it's been improved in 1.2. For now, you probably > have an installation issue. Try removing the DDS decoder for a better error > message, or substitute the image for one that you know works. > Ah, thanks. I moved the sample and image to another directory, and all running fine now. I still don't know why my code failed, but it turned out that I had to cache the data for the entire image, because get_data is too slow on a frame by frame basis (I am running per-pixel collision detection on animated sprites). While we are on the topic of sprites, I have a patch that adds pausing, seeking and looping on ranges to pyglet.sptie.Sprite's animation playback - would you be interested in it? Alex. > > On Tue, Dec 23, 2008 at 6:40 PM, Alex Holkner < <[email protected]> > [email protected]> wrote: > >> >> On 12/24/08, Tristam MacDonald < <[email protected]> >> [email protected]> wrote: >> > Has anyone had any luck using ImageDataRegion.get_data()? I always get >> the >> > following error when trying to call it: >> > >> > File >> > "/Library/Python/2.5/site-packages/pyglet/image/__init__.py", >> > line 1142, in get_data >> > rows = [row[x1:x2] for row in >> > rows[self.y:self.y+self.height]] >> > TypeError: slice indices must be integers or None or have an __index__ >> > method >> > >> > I have tried this every which way, so I don't think I am doing anything >> > wrong. If anyone has any thoughts, or perhaps a working code sample, I >> would >> > love to check it out. >> >> Here's a (not very useful) working example. If you're still having >> trouble, perhaps post a code sample that doesn't work. >> >> import pyglet >> i = pyglet.image.load('examples/programming_guide/kitten.jpg') >> d = i.get_image_data() >> d.get_region(20, 20, 40, 40) >> d.get_data('RGBA', d.pitch) >> >> Alex. >> >> >> > > > -- > Tristam MacDonald > <http://swiftcoder.wordpress.com/>http://swiftcoder.wordpress.com/ > > > > > > -- Tristam MacDonald http://swiftcoder.wordpress.com/ --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "pyglet-users" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/pyglet-users?hl=en -~----------~----~----~----~------~----~------~--~---
