Jump to content

  • Log In with Google      Sign In   
  • Create Account


#ActualVaclav

Posted 04 September 2012 - 01:57 AM

I try to access a pixel on a surface with the getpixel function from SDL's help:
http://sdl.beuc.net/...ki/Pixel_Access

It works for 32bit surfaces, but gives segfault for 8bit surfaces at line return *p; after case 1:.
If I change that line to return *(Uint32*)p; I don't get segfault, but when I try to use the returned value by either SDL_GetRGB or SDL_GetRGBA, I get segfault, so the returned value is obviously incorrect. (However with the 32bit surface these functions work, so it's not me using them wrong way.)
I haven't tested for 16 or 24 bit surfaces.
Aslo the 32bit surface was loaded from a png with per pixel alpha, but the 8bit surface was loaded from a bmp with colorkey alpha, but I don't think this matters.
Any idea how to get it working?

#1Vaclav

Posted 03 September 2012 - 05:10 AM

I try to access a pixel on a surface with the getpixel function from SDL's help:
http://sdl.beuc.net/...ki/Pixel_Access

It works for 32bit surafes, but gives segfault for 8bit surfaces at line return *p; after case 1:.
If I change that line to return *(Uint32*)p; I don't get segfault, but when I try to use the returned value by either SDL_GetRGB or SDL_GetRGBA, I get segfault, so the returned value is obviously incorrect. (However with the 32bit surface these functions work, so it's not me using them wrong way.)
I haven't tested for 16 or 24 bit surfaces.
Aslo the 32bit surface was loaded from a png with per pixel alpha, but the 8bit surface was loaded from a bmp with colorkey alpha, but I don't think this matters.
Any idea how to get it working?

PARTNERS