class SDL_array(ptr, count, ctype)

Bases: object


Access the array as raw bytes, regardless of the underlying data type.

This can be useful, for example, in accessing a 32-bit colour buffer by individual components rather than the encoded pixel.

Return type:SDL_array

Access the array as a ctypes array.

Return type:ctypes.Array

Access the array as 16-bit integers, regardless of the underlying data type.

Return type:SDL_array

Access the array as 32-bit integers, regardless of the underlying data type.

Return type:SDL_array

Access the array as a numpy array.

The numpy array shares the same underlying memory buffer, so changes are immediate, and you can use the numpy array as you would normally. To set the entire contents of the array at once, use a [:] slice.

If numpy is not installed, an ImportError will be raised.

Return type:numpy.ndarray

Copy string data into this array.

The string must have exactly the same length of this array (in bytes). No size checking is performed.

data : str

String data to copy.


Determine if the numpy array module is available.

Return type:bool

Return a string with the contents of this array.

Return type:string
to_ctypes(values, count, ctype)

Create a ctypes array of the given count and type, with the contents of sequence values.

  • values: sequence of length count, or SDL_array instance, or ctypes.Array, or POINTER(ctypes.Array)
  • count: int
  • ctype: type
Return type:

object, ctypes.Array


(ref, array), where ref is an object that must be retained by the caller for as long as the array is used.