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

Re: [pygame] numpy array module now in the pygame development tree



So array2d can handle 24 bit pixels. It is pixels2d that does not. But the test program does raise the following exception when the test surface has 24 bit pixels.

Traceback (most recent call last):
 File "ac_bug.py", line 6, in <module>
   ac = py.numpyarray.array_colorkey(s)  # Raises exception
File "C:\PRG\PYTHON25\lib\site-packages\pygame\numpyarray.py", line 312, in ar
ray_colorkey
   array = numpy.choose (numpy.equal (array, colorkey), (0xff, 0))
ValueError: shape mismatch: objects cannot be broadcast to a single shape


The code is also inefficient, not making proper use to numpy's type system. Using (numpy.uint8(0xff), numpy.uint8(0)) as the second argument to choose returns an array of uint8.

Lenard Lindstrom wrote:
Lenard Lindstrom wrote:
Lenard Lindstrom wrote:

It's good to see. Unfortunately I have already found a bug in the numpyarray.py module, line 217. A 3d array can also handle 24 bit pixels. So the third element of the shape needs be calculated.


I have another bug. Attached is a program which raises the following exception:

Traceback (most recent call last):
 File "ac_bug.py", line 6, in <module>
   ac = py.numpyarray.array_colorkey(s)  # Raises exception
File "C:\PRG\PYTHON25\lib\site-packages\pygame\numpyarray.py", line 309, in ar
ray_colorkey
   array = array2d (sf)
NameError: global name 'sf' is not defined


Just a guess, but sf probably should be surface.



I made the change myself and found that array_colorkey breaks for a 24 bit pixel surface since it calls array2d, which definitely cannot handle 24 bit pixels.



--
Lenard Lindstrom
<len-l@xxxxxxxxx>