BGR Image Format

I’m writing a program with SDL and OpenGL
that currently loads an MD2 model textured
with a PCX file.

When I load the same texture as a TGA
(all of this with the SDL_image library)
I notice that the Red and Blue values
appear to be swapped. I attribute this
to the fact that PCX files are RGB while
TGA files are BGR (or something like that).

How would I change the format to RGB after
the SDL_Surface is loaded.

I’m guessing I need to loop through
surface->pixels swapping some values. Anyone
help out?

Also, how can I detect what format the image
is in, so I know whether to swap or not.

Any help appreciated.

-Randall–

Randall wrote:

How would I change the format to RGB after
the SDL_Surface is loaded.

BlitSurface automatically converts from one format to another when copying
between surfaces. Please read the documentation

for an example, see ftp://ptah.lnf.kth.se/pub/misc/convgltex.c

Thanks for the tip.

“Mattias Engdeg?rd” a ?crit dans le message news:
mailman.1003091467.25973.sdl at libsdl.org…> Randall wrote:

How would I change the format to RGB after
the SDL_Surface is loaded.

BlitSurface automatically converts from one format to another when copying
between surfaces. Please read the documentation

for an example, see ftp://ptah.lnf.kth.se/pub/misc/convgltex.c