2D and 3D direct pixel access¶
-
class
sdl2.ext.PixelView(source : object)¶ 2D
MemoryViewforSoftwareSpriteandsdl2.SDL_surfacepixel access.Note
If necessary, the source surface will be locked for accessing its pixel data. The lock will be removed once thePixelViewis garbage-collected or deleted.The
PixelViewuses 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
PixelViewis implemented on top of theMemoryViewclass. 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 aSoftwareSpriteorsdl2.SDL_Surface. TheSDL_Surfaceof 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.UnsupportedErrorwill be raised.
-
sdl2.ext.pixels3d(source : object)¶ Creates a 3D pixel array, based on
numpy.ndarray, from the passed source. source can be aSoftwareSpriteorsdl2.SDL_Surface. TheSDL_Surfaceof 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.UnsupportedErrorwill be raised.