Sign in to follow this  
RedRabbit

SDL_Reverse?

Recommended Posts

I don't know about SDL, but you can flip an image by scaling it by -1. But I don't know if SDL has a SDL_Scale or whatever...

Share this post


Link to post
Share on other sites
no, but it is pretty easy to write it yourself.


SDL_Surface *xmirror(SDL_Surface *toflip)
{
SDL_Surface *surface =
SDL_CreateRGBSurface(SDL_SWSURFACE, toflip->w, toflip->h, toflip->format->BitsPerPixel, 0, 0, 0, 0);

for (int x = 0; x < surface->w; x++)
for(int y = 0; y < surface->h; y++)
putpixel(surface, surface->w-x-1,y, getpixel(toflip,x,y));


return surface;
}

SDL_Surface *ymirror(SDL_Surface *toflip)
{
SDL_Surface *surface =
SDL_CreateRGBSurface(SDL_SWSURFACE, toflip->w, toflip->h, toflip->format->BitsPerPixel, 0, 0, 0, 0);

for (int x = 0; x < surface->w; x++)
for (int y = 0; y < surface->h; y++)
putpixel(surface, x,surface->h-y-1,getpixel(toflip,x,y));

return surface;
}







as for getpixel and putpixel functions, just google them or search them on the SDL mailing list.

[Edited by - clayasaurus on October 3, 2004 5:31:53 PM]

Share this post


Link to post
Share on other sites
Check out some of the add-on SDL libs like SDL_gfx. They provide rotozoom functions and much more. Go straight to the SDL website for a list of available libs.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this