Exemple #1
0
def make_surface(array):
    """pygame.surfarray.make_surface (array): return Surface

    Copy an array to a new surface.

    Create a new Surface that best resembles the data and format on the
    array. The array can be 2D or 3D with any sized integer values.
    """ 
    if isinstance(array, numpy_ndarray) and array.dtype in numpy_floats:
        array = numpy_rint(array, numpy_empty(array.shape, dtype=numpy_uint32))
    return pix_make_surface (array)
Exemple #2
0
def blit_array (surface, array):
    """pygame.surfarray.blit_array(Surface, array): return None

    Blit directly from a array 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 = numpy_rint(array, numpy_empty(array.shape, dtype=numpy_uint32))
    return array_to_surface(surface, array)