Uint32 getpixel(SDL_Surface *surface, int num)
{/*pxl direct read access*//**1.0**/
int bpp = surface->format->BytesPerPixel;
/* P est l'adresse du pixel à retrouver*/
uint8_t *p = (uint8_t *)surface->pixels + num * bpp;
switch(bpp) {
case 1:
return *p;
case 2:
return *(Uint16 *)p;
case 3:
if(SDL_BYTEORDER == SDL_BIG_ENDIAN)
return p[0] << 16 | p[1] << 8 | p[2];
else
return p[0] | p[1] << 8 | p[2] << 16;
case 4:
return *(Uint32 *)p;
default:
return 0;
}
}
best i could find for now... most other get_rgb sources i found were not reading from the screen i believe this is. this looks like it returns rgb if im understanding this.
Bookmarks