Jump to content
  • Advertisement
Sign in to follow this  
RedRabbit

SDL_Reverse?

This topic is 5402 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Advertisement
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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!