1 Sep 2009 16:38
Re: SDL_GetRGBA exits program.
Jonathan Dearborn <grimfang4 <at> gmail.com>
2009-09-01 14:38:00 GMT
2009-09-01 14:38:00 GMT
Just to make the usage clear, in C you set up the variables:
Uint8 r, g, b, a;
SDL_Surface* theimage = IMG_Load("test.png");
Uint32 pixel = SDL_GetPixel(theimage, x, y);
Then pass the color components by reference (pass pointers to them):
SDL_GetRGBA(pixel, theimage->format, &r, &g, &b, &a);
SDL fills in the color components found in 'pixel' according to the
format that is given. The memory for the color component variables
must be allocated already (I've done this statically here, instead of
using 'malloc' or 'new') or else bad things will happen (like
crashes).
Also, I should note that your SDL_GetPixel call has swapped 'x' and 'y'.
Hope that helps,
Jonny D
On Tue, Sep 1, 2009 at 9:33 AM, Christian
Knudsen<webmaster <at> asciisector.net> wrote:
> Christian Knudsen <webmaster <at> asciisector.net> writes:
>
>> I'm on WinXP Home Edition SP2 and using SDL 1.2.13. I've got a Linux machine
>> as well. I'll see if I get the same result there.
>
>
> Same exact thing in Ubuntu 8.04. The program just exits when reaching the
> SDL_GetRGBA call without any error messages.
>
> _______________________________________________
> SDL mailing list
> SDL <at> lists.libsdl.org
> http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
>
RSS Feed