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

Re: [pygame] Bug (?): Pygame 1.8 Surface.get_buffer strangeness for 24 bit pixels



On, Mon Jan 07, 2008, Lenard Lindstrom wrote:

> Pygame 1.8 for Python 2.5 on Windows:
> 
> For a surface with 24 bit pixels, the buffer returned by the get_buffer 
> method is not necessarily the same size as the product of the surface's 
> width, height, and pixel byte size of 3. The attached program demonstrates. 
> This discrepancy breaks the pixels3d function of the new numpyarray module.

Already fixed in SVN, but using a different approach.

The surface's pitch is a the length of one scanline in bytes. Multiplied
with the height of the surface, this gives the absolute byte size:

     s.get_pitch () * s.get_height ().

For a 10x10 24bpp surface this'd be 320 bytes, not 300 as your
calculation would cause.

The pixels3d() function was broken, because I thought abusing the strides
and using 4bpp access can do anything for 3 bytes. Do not ask me why I
did that. It is fixed now in rev. 1069.

Regards
Marcus

Attachment: pgp2a1QUUlv8o.pgp
Description: PGP signature