Hi,
Well no, the post 1.9.1 surfarray does not support float arrays. The
NumPy code was rewritten in C to make the module more general and,
hopefully, faster. I'm sorry if it breaks some code. That the previous,
pure Python, version converted a NumPy array of floats into an integer
array may have been an unintended side affect. It would certainly make
no sense. NumPy differs from Numeric in that it defaults to a float
array. So any NumPy array used with surfarray should be created with an
explicit, integer, dtype. If float arrays are needed somewhere in the
calculation then they can be converted to integer arrays with the
astype() method, just as the 1.9.1 surfarray did.
I suppose astype() conversion call could be put back into surfarray, but
I don't see the need. Implicit, undocumented, conversions can lead to
surprises. It would also add an extra, unnecessary, step.
Lenard Lindstrom
On 24/08/11 03:48 PM, Ian Mallett wrote:
Hi,
A user of glLib reported an error. The error boils down to:
File "c:\python27\lib\site-packages\glLib\glLibParticles.py", line
83, in __init__
surface = pygame.surfarray.make_surface(rgb)
File "c:\python27\lib\site-packages\pygame\surfarray.py", line 320,
in make_surface
return numpysf.make_surface (array)
File "c:\python27\lib\site-packages\pygame\_numpysurfarray.py", line
318, in make_surface
array_to_surface(surface, array)
ValueError: unsupported array type 'f'
The input surface to pygame.surfarray.make_surface is a NumPy float
array (n*n*3).
My PyGame version is '1.9.1release-svn2575', (which I recall is
somewhat older) and he reports using "the latest". I am using Python
2.6, and he is using Python 2.7. I wasn't able to find where the
problem would occur in (my version of) the PyGame source. I also
cannot reproduce the problem.
Help? Thanks,
Ian