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

Re: [pygame] surfarray on 64-bit machines



On Sat, Feb 28, 2009 at 10:53:56AM -0800, Lenard Lindstrom wrote:
> Marius Gedminas wrote:
>> On Fri, Feb 27, 2009 at 08:04:30PM -0800, Lenard Lindstrom wrote:
>>> But arithmetic operations have ufunc equivalents which take an 
>>> optional  output array. This means the astype(), along with its 
>>> intermediate  array, can be removed. It probably also means the 
>>> intermediate array  float array goes away as well. So it is likely 
>>> this alternative uses no  intermediate arrays.
>>>
>>> ## array = pygame.surfarray.pixels_alpha(image)
>>> alpha = 42.5
>>> ## array[...] = (mask * alpha / 255).astype('b')
>>> numpy.multiply(mask, alpha  /  255, pygame.surfarray.pixels_alpha(image))
>>
>> Unfortunately this gives me a TypeError: return arrays must be of ArrayType
>>
> I'm guessing you have both Numeric and NumPy installed.

Yes; and since I'm not writing for myself only, I'd like the code to
work with all possible combinations of Numeric/NumPy/PyGame versions.
(I have fallbacks in place when numpy or Numeric cannot be important.)

> Try
>
> pygame.surfarray.user_arraytype('numpy')
>
> at the start. NumPy became the default only recently with 1.9.

Unfortunately, this gives me

  AttributeError: 'module' object has no attribute 'user_arraytype'

I've got pygame 1.8.1 here (Ubuntu's 1.8.1release-0ubuntu1 to be precise)

Marius Gedminas
-- 
Q: A good ninja is hard to find.
A: Well, yes, actually, being hard to find is the whole point with them.
        -- http://tinyurl.com/5tnrwr

Attachment: signature.asc
Description: Digital signature