Accessing SDL_Surface Pixel Array in pySDL2

Viewed 22

I'm trying to access pixel data from an SDL_Surface in PySDL2, I have been able to access the width and height of the surface using surface.contents.h, however surface.contents.pixels only return an int. Looking at the API reference, i believe that this is a pointer to the pixel array. I only need to read the pixels, not overwrite them.

surface = sdl2.sdlttf.TTF_RenderText_Blended(
            font, contents.encode(), sdl2.SDL_Color(*colour))

        surf = surface.contents
0 Answers
Related