How do I read the RGBA values of a pixel from a surface or texture with SDL2? lazarus / 39-Graphics ---------------------------------------------------------------------- semichaud1 · 2019-12-01 16:26 Hi, How do I read the RGBA values of a specific pixel, at given coordinates x and y, from a surface or texture with SDL2 in Free Pascal? Thanks. ---------------------------------------------------------------------- piXelicidio · 2019-12-17 13:45 Hi, you can't or shouldn't read pixels from a texture because its on GPU memory. Only from surfaces: When you create the surface with (https://wiki.libsdl.org/SDL_CreateRGBSurface) maybe with 32 bits in the deph parameter. Then it returns an structure (record): https://wiki.libsdl.org/SDL_Surface There you can get and access anytime the "pixels" pointer. From that record you need also pitch to make your custom getpixel and setpixel. ---------------------------------------------------------------------- metis · 2019-12-20 17:09 @semichaud1 and then try it with SDL_GetDisplayDPI(...);  // Get diagonal, horizontal, vertical DPI and SDL_GetRGBA(...); // Get the Pixel's RGBA-Values ---------------------------------------------------------------------- metis · 2020-05-30 14:49 @semichaud1 with 'SDL_RenderReadPixels()' you may get the Pixels from a Texture w/o creating a Surface in Your Code, see: https://discourse.libsdl.org/t/most-efficient-way-of-getting-render- pixels/27581.