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

Re: [pygame] Simple Surfarray Alpha



Then you are using Numeric, not NumPy. That's strange, because I was getting a different error message for Numeric with Python 2.5. With 2.4 it is the same as yours. Numeric does a silent upcast of its type, so you end up trying to assign an array of 4 byte integers to an array of bytes. To combat the upcasting try this before the assignment:

array.savespace(1)

By the way, NumPy doesn't do this automatic upcasting. It was a source of frustration at first since it subtly broke the Pygame surfarray example. But I see now why the change.

Lenard


Ian Mallett wrote:
The first line gives:
(300, 400) (16711680, 65280, 255, -16777216) (16, 8, 0, 24)
The second crashes with an AttributeError at "dtype".