SDL_GetRGB and 24 Bits surface

Hello,

I’ve got a simple question about SDL_GetRGB and 24 bits surface.
I’m using this function on a 32 bits without any problem, but on 24 bits
surface it seems that the red an blue value are swapped.

It looks like an endian related behaviour, but i thought that the use of
these function allow me to “forget” about the target architecture.

Should i make my own routines to avoid that or i’m missing something (i’m
quite sure i’m am).

Thanx !

Hi there,

about your problem there is something written on the SDL Manual page about it. This is what i used alot together with SDL_SurfaceCreate* functions. Maybe it helps…

#if SDL_BYTEORDER == SDL_BIG_ENDIAN
rmask = 0xff000000;
gmask = 0x00ff0000;
bmask = 0x0000ff00;
amask = 0x000000ff;
#else /* /
rmask = 0x000000ff;
gmask = 0x0000ff00;
bmask = 0x00ff0000;
amask = 0xff000000;
#endif /
*/

I’ve got a simple question about SDL_GetRGB and 24 bits surface.
I’m using this function on a 32 bits without any problem, but on 24 bits
surface it seems that the red an blue value are swapped.

It looks like an endian related behaviour, but i thought that the use of
these function allow me to “forget” about the target architecture.

No you can’t. Red and Blue are on some systems swaped around. You will have to do it like the manual says.

have a good time,
Steffen

I was quite sure i was using those masks. Of course, it was not the
case… :smiley:

Thanx for your quick answer !