# Surface rotation and scaling

- sge_transform
- sge_transform_surface

SDL_Rect sge_transform(SDL_Surface *src, SDL_Surface *dst, float angle, float xscale, float yscale, Uint16 px, Uint16 py, Uint16 qx, Uint16 qy, Uint8 flags)
Draws a rotated and scaled version of src on dest.

- SDL_Surface *src - The surface to be rotated and scaled.
- SDL_Surface *dst - The surface where the result should be drawn.
- float angle - The rotation angle in degrees.
- float xscale / yscale - The x and y scaling factor. Can be negative (mirroring). 1.0 is 1:1 scale.
- Uint16 px / py - The pivot point to rotate around in the src surface.
- Uint16 qx / qy - The destination point on dst surface.
- Uint8 flags - See below.

Flags: (may be ORed, eg. SGE_TAA|SGE_TSAFE)

- 0 - Default.
- SGE_TAA - Use the interpolating renderer. Much slower but can look better.
- SGE_TSAFE - Don't asume that the src and dst surfaces has the same pixel format. This is the default when the two surfaces don't have the same BPP. This is slower but will render wierd pixel formats right.
- SGE_TTMAP - Use texture mapping. This is a bit faster but the result isn't as nice as in the normal mode. This mode will also ignore the px/py coordinates and the other flags.

To get optimal performance PLEASE make sure that the two surfaces has the same pixel format (color depth) and doesn't use 24-bpp.
Note:</n>

- You can set source and destination clipping rectangles with SDL_SetClipRect().
- If you use the interpolated renderer the image will be clipped 1 pixel in hight and width (to optimize the performance).
- If you want to transform a 32-bpp RGBA (alpha) surface with the interpolated renderer, please use the SGE_TSAFE flag.
- This function will not do any alpha blending, but it will try to preserve the alpha channel. If you want to rotate and alpha blend the result, please use sge_transform_surface() and then blit that surface to its destination.

Does lock the surfaces.
Returns SDL_Rect: The size and position (bounding box) of the rendered image on dst surface.

SDL_Surface *sge_transform_surface(SDL_Surface *src, Uint32 bcol, float angle, float xscale, float yscale, Uint8 flags)
Returns a rotated and scaled version of src. See sge_transform() for more information.

- Uint32 bcol - What background color should the new surface have? This pixel value should be mapped with SDL_MapRGB/SDL_MapRGBA on the src surface.

The new surface will have the same depth and pixel format as the src surface.
Returns SDL_Surface*: A pointer to the new surface or NULL on failure. Don't forget to free this surface later with SDL_FreeSurface().

Copyright © 1999-2003 Anders Lindström
Last updated 030808