On, Thu Apr 10, 2008, Lenard Lindstrom wrote: [...] > The problem always comes down to 24 bit per pixel surfaces. > > >>> import numpy > >>> numpy.__version__ > '1.0.4' > >>> import pygame > >>> surface = pygame.Surface((7,2), 0, 24) > >>> bpp = surface.get_bytesize() > >>> print bpp, surface.get_width()*bpp, surface.get_pitch() > 3 21 24 > >>> array = numpy.frombuffer (surface.get_buffer (), numpy.uint8) > >>> array.shape = surface.get_height (), surface.get_pitch () > >>> array = array[:,:surface.get_width () * bpp] > >>> array.shape = surface.get_width (), surface.get_height (), bpp > > Traceback (most recent call last): > File "<pyshell#18>", line 1, in <module> > array.shape = surface.get_width (), surface.get_height (), bpp > AttributeError: incompatible shape for a non-contiguous array > >>> Thanks. Though the numpy.reshape () method might return a copy if needed, it seems to be safe enough for our cases as the shape changes are made on the array itself all the time. At least i I can trust the id() and my eyes ;-). Thanks for the fix, Lorenz, it's commited in rev. 1199. Regards Marcus
Attachment:
pgpOhXKjLycyM.pgp
Description: PGP signature