#include "retourner.h" SDL_Surface* retournement(SDL_Surface* originale, int nbQuarts) { //Création de la seconde surface SDL_Surface* pivot(0); if (nbQuarts%2) pivot=SDL_CreateRGBSurface(SDL_HWSURFACE,originale->h,originale->w,32,0,0,0,0); else pivot=SDL_CreateRGBSurface(SDL_HWSURFACE,originale->w,originale->h,32,0,0,0,0); //Photocopie quart de tour SDL_Rect fromPos={0,0,1,1}; SDL_Rect toPos={0,0,0,0}; for (fromPos.x = 0; fromPos.x < originale->w; fromPos.x++) for (fromPos.y = 0; fromPos.y < originale->h; fromPos.y++) { if (nbQuarts%4 == 0) { toPos.x=fromPos.x; toPos.y=fromPos.y; } if (nbQuarts%4 == 1) { toPos.x=originale->h-fromPos.y; toPos.y=fromPos.x; } if (nbQuarts%4 == 2) { toPos.x=originale->w-fromPos.x; toPos.y=originale->h-fromPos.y; } if (nbQuarts%4 == 3) { toPos.x=fromPos.y; toPos.y=originale->w-fromPos.x; } SDL_BlitSurface(originale,&fromPos,pivot,&toPos); } return pivot; }