SDL_Reverse?

Started by
3 comments, last by leiavoia 19 years, 6 months ago
is there an SDL function to reverse or *flip* an image? ie: image: d image reverse: b thanks
//-----------------------------------------One short sleepe past, wee wake eternally, And Death shall be no more, Death thou shalt die.
Advertisement
in short, no.

but, check out this site
here
and see if you can find anything.
gib.son
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...
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]
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.

This topic is closed to new replies.

Advertisement