2D and 3D direct pixel access¶
-
class
sdl2.ext.
PixelView
(source : object)¶ 2D
MemoryView
forSoftwareSprite
andsdl2.SDL_surface
pixel access.Note
If necessary, the source surface will be locked for accessing its pixel data. The lock will be removed once thePixelView
is garbage-collected or deleted.The
PixelView
uses a y/x-layout. Accessingview[N]
will operate on the Nth row of the underlying surface. To access a specific column within that row,view[N][C]
has to be used.Note
PixelView
is implemented on top of theMemoryView
class. As such it makes heavy use of recursion to access rows and columns and can be considered as slow in contrast to optimised ndim-array solutions such asnumpy
.
-
sdl2.ext.
pixels2d
(source : object)¶ Creates a 2D pixel array, based on
numpy.ndarray
, from the passed source. source can be aSoftwareSprite
orsdl2.SDL_Surface
. TheSDL_Surface
of the source will be locked and unlocked automatically.The source pixels will be accessed and manipulated directly.
Note
pixels2d()
is only usable, if the numpy package is available within the target environment. If numpy could not be imported, asdl2.ext.compat.UnsupportedError
will be raised.
-
sdl2.ext.
pixels3d
(source : object)¶ Creates a 3D pixel array, based on
numpy.ndarray
, from the passed source. source can be aSoftwareSprite
orsdl2.SDL_Surface
. TheSDL_Surface
of the source will be locked and unlocked automatically.The source pixels will be accessed and manipulated directly.
Note
pixels3d()
is only usable, if the numpy package is available within the target environment. If numpy could not be imported, asdl2.ext.compat.UnsupportedError
will be raised.