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

Re: [pygame] PixelArray vs SurfArray



On, Sat Mar 07, 2009, Ian Mallett wrote:

> Hi
> 
> I'm working on a project, and it would be really nice to have fast access to
> pixel data.  I'm thinking that PixelArray or SurfArray will do the job--but
> what's the difference between the two?  I know that surfarray requires
> Numeric or NumPy, but I'm less familiar with PixelArray--does it have such a
> requirement?  Are there other differences?

PixelArray has no third-party requirements, but also does not provide
all the shiny features, NumPy and Numeric offer. It's pixel access is
limited to 2D only. Values are usually represented as integer values (so
you'll require a call to map_rgb() for specific R, G or B values, if you
have the requirement to work with different surface formats).

For basic operations such as slicing, indexing and direct value
manipulations, PixelArray is very fast and in nearly all cases even
faster than Surfarray. If you need to do looped operations or similar
things, that contain more complex operations, you might want to consider
NumPy/Numeric and their ufuncs, however.

Regards
Marcus

Attachment: pgpI8feWBSUl3.pgp
Description: PGP signature