B. Bogart wrote:
Alex Holkner wrote:
Using surfarray.pixels2d will give you a Numeric array overlayed over
the buffer, you can extract the buffer pointer with a little ctypes
hackery (see array.py in pygame-ctypes).
Hi Alex,
The updated docs on the pygame website say that numarray is compatible
with surfarray, but blit_array does not accept a numarray argument. Is
only numeric supported?
The docs you are looking at are for Pygame-ctypes. Standard Pygame
accepts only Numeric arrays (though I vaguely remember a patch floating
around a while back for numpy).
Here is the original message:
Hey all,
So I'm just looking for a good way to get pixel access to images in python.
Seems surfarray is a great option. The manual states that I can use
numarray,numpy or numeric:
"Any type of array (numpy, numarray or Numeric) can be used as the input
to any function regardless of the array module set."
(from http://www.pygame.org/ctypes/pygame-api/pygame.surfarray-module.html)
I have chosen numarray and I suppose will eventually change to numpy.
Even within Pygame-ctypes, numarray is not supported completely: I'd
recommend using numpy if possible.
but it seems I am actually not allowed to pass a numarray to a surfarray
function:
type(image)
<class 'numarray.numarraycore.NumArray'>
pygame.surfarray.blit_array(mysurface, image)
Traceback (most recent call last):
File "<stdin>", line 1, in ?
TypeError: argument 2 must be array, not NumArray
It looks like there is no random_array module in numeric nor numpy,
just numarray.
See numpy.random.
Alex.