Flipping an SDL_Surface

I was wondering if anyone knew how to have one
image that was facing left to face right and vice versa once
they are loaded into an SDL_Surface and have it return another
SDL_Surface with the flipped image. Thanks in advance.

Brendan

Assuming its a 32-bit surface:

SDL_Surface *flipSurface(SDL_Surface *sin)
{
SDL_Surface *sout;
Uint32 sin_offset, sout_offset;
int x,y;
sout=SDL_CreateRGBSurface(SDL_SWSURFACE, sin->w, sin->h,
32,
sin->format->Rmask,
sin->format->Gmask,
sin->format->Bmask,
sin->format->Amask);
sin_offset=(Uint32
)sin->pixels;
for(y=0;yh;y++)
{
sout_offset=((Uint32
)sout->pixels)+((y+1)*sout->w);
for(x=0;xw;x++)
(–sout_offset)=(sin_offset++);
}
return sout;
}On Sun, 30 Apr 2000, Brendan Allen wrote:

I was wondering if anyone knew how to have one
image that was facing left to face right and vice versa once
they are loaded into an SDL_Surface and have it return another
SDL_Surface with the flipped image. Thanks in advance.

Brendan

Martin

Bother! said Pooh, as the others burned him at the stake.