Restore double to integer convertion to _numpysurfarray.make_surface and blit_array

Lenard Lindstrom avatarLenard Lindstrom created an issue

The pure Python version of blit_array called the NumPy array
method to size the array for copying to the surface. A side affect of this was to convert float arrays to int. This behavior was removed in Pygame 1.9.2 when the _numpysurfarray code was reimplemented in C.

As it turns out, developers have come to expect the implicit conversion of float to int arrays, as brought up in this mailing list thread: So this issue is to add the implicit conversion back into _numpysurfarray. It will not involve the pixelcopy module, so has has no significant impact on future optimizations of array blits.

It was suggested that rounding floats to int would be more useful than simple truncation. This possibility will be explored. If it is impractical then the simple astype call will be reinstituted.

Comments (5)

  1. Lenard Lindstrom

    Let _numpysurfarray.blit_array and make_surface methods accept float arrays ( closes #81 )

    As requested, surfarray once again excepts numpy arrays with a float dtype. Float values are rounded to int with the numpy.rint ufunc. In Pygame 1.9.1, floats were simply truncated.


  2. Log in to comment
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.