SDL_GetRGBA Problems

I’m loading a 24-bit TGA image with the SDL_image library
and then I’m looping through the pixels and calling
SDL_GetRGBA on each…and I’m noticing some wierd
problems. To find out what’s wrong I’m using solid images
of only one color at a time.

Here’s the chart of my results showing the color values
returned for every pixel of an image of a given color.

				SDL_GetRGBA Call Results

Image Color Red Green Blue_________________________________________
Red 0 255 0
Green 0 0 255
Blue 255 0 0

Understanding that a TGA is a BGR image, I also tested
a PCX file to see if the same problems persisted.

				SDL_GetRGBA Call Results

Image Color Red Green Blue

Red 0 0 255
Green 255 0 0
Blue 0 255 0

I am unable to explain this problem. My first thought is that
SDL_GetRGBA is not working correctly, but I suspect this is
not the case, as people would have reported this bug a long
time ago. My next thought is that SDL_image is not setting
variables in the SDL_Surface correctly. I want to know if anyone
else is having a similar problem. I’m working under MacOS
10.1.2 on an iMac 400mhz with an ATI Rage 128.

Randall Leeds

Randall Leeds wrote:

Understanding that a TGA is a BGR image,

The format of the surface that SDL_image returns is not necessarily the
same as in the format on disk. It is also subject to change whenever
the library maintainers think it’s useful to do so