-
-
Notifications
You must be signed in to change notification settings - Fork 230
Open
Description
def blit_array(surface, array):
"""pygame.surfarray.blit_array(Surface, array): return None
Blit directly from an array of values.
Directly copy values from an array into a Surface. This is faster than
converting the array into a Surface and blitting. The array must be the
same dimensions as the Surface and will completely replace all pixel
values. Only integer, ascii character and record arrays are accepted.
This function will temporarily lock the Surface as the new values are
copied.
"""
if isinstance(array, numpy_ndarray) and array.dtype in numpy_floats:
array = array.round(0).astype(numpy_uint32)
return array_to_surface(surface, array)
it's explicitly mentioned that Only integer, ascii character and record arrays are accepted., but pygame-ce will also accept floats and implicitly run a costly conversion instead, which is surprising because this is meant to be a more performance oriented API. I can't seem to find anywhere where this behaviour is documented, I discovered it by accident myself when debugging a path that mistakenly outputted a float array, and performance tanked implicitly as a result.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels