When working with SDL_gfx you need to be as careful as when working SDL_DisplayFormat or SDL_DisplayFormatAlpha, so source surface and dest surface must not be the same and use SDL_FreeSurface() when you don't the surface any more or else your application will leak memory.

Also, SDLUtils.pas provides a rotation function out-of-the-box, but is not as reliable as SDL_gfx.