31 #include "../../SDL_internal.h" 33 #if defined(__WIN32__) 34 #include "../../core/windows/SDL_windows.h" 65 #define MAX(a,b) (((a) > (b)) ? (a) : (b)) 77 #define GUARD_ROWS (2) 82 #define VALUE_LIMIT 0.001 110 int *dstwidth,
int *dstheight,
111 double *cangle,
double *sangle)
113 double x,
y, cx, cy, sx, sy;
115 int dstwidthhalf, dstheighthalf;
120 radangle = angle * (
M_PI / 180.0);
123 x = (double)(width / 2);
124 y = (double)(height / 2);
130 dstwidthhalf =
MAX((
int)
132 dstheighthalf =
MAX((
int)
134 *dstwidth = 2 * dstwidthhalf;
135 *dstheight = 2 * dstheighthalf;
161 int x,
y,
t1, t2, dx, dy, xd, yd, sdx, sdy, ax, ay, ex, ey, sw, sh;
169 xd = ((src->
w - dst->
w) << 15);
170 yd = ((src->
h - dst->
h) << 15);
171 ax = (cx << 16) - (icos * cx);
172 ay = (cy << 16) - (isin * cx);
176 gap = dst->
pitch - dst->
w * 4;
182 for (y = 0; y < dst->
h; y++) {
184 sdx = (ax + (isin * dy)) + xd;
185 sdy = (ay - (icos * dy)) + yd;
186 for (x = 0; x < dst->
w; x++) {
189 if (flipx) dx = sw - dx;
190 if (flipy) dy = sh - dy;
191 if ((
unsigned)dx < (unsigned)sw && (
unsigned)dy < (unsigned)sh) {
196 sp += (src->
pitch/4);
201 cswap = c00; c00=c01; c01=cswap;
202 cswap = c10; c10=c11; c11=cswap;
205 cswap = c00; c00=c10; c10=cswap;
206 cswap = c01; c01=c11; c11=cswap;
213 t1 = ((((c01.
r - c00.
r) * ex) >> 16) + c00.
r) & 0xff;
214 t2 = ((((c11.
r - c10.
r) * ex) >> 16) + c10.
r) & 0xff;
215 pc->
r = (((t2 -
t1) * ey) >> 16) + t1;
216 t1 = ((((c01.
g - c00.
g) * ex) >> 16) + c00.
g) & 0xff;
217 t2 = ((((c11.
g - c10.
g) * ex) >> 16) + c10.
g) & 0xff;
218 pc->
g = (((t2 -
t1) * ey) >> 16) + t1;
219 t1 = ((((c01.
b - c00.
b) * ex) >> 16) + c00.
b) & 0xff;
220 t2 = ((((c11.
b - c10.
b) * ex) >> 16) + c10.
b) & 0xff;
221 pc->
b = (((t2 -
t1) * ey) >> 16) + t1;
222 t1 = ((((c01.
a - c00.
a) * ex) >> 16) + c00.
a) & 0xff;
223 t2 = ((((c11.
a - c10.
a) * ex) >> 16) + c10.
a) & 0xff;
224 pc->
a = (((t2 -
t1) * ey) >> 16) + t1;
233 for (y = 0; y < dst->
h; y++) {
235 sdx = (ax + (isin * dy)) + xd;
236 sdy = (ay - (icos * dy)) + yd;
237 for (x = 0; x < dst->
w; x++) {
240 if ((
unsigned)dx < (unsigned)src->
w && (
unsigned)dy < (unsigned)src->
h) {
241 if(flipx) dx = sw - dx;
242 if(flipy) dy = sh - dy;
275 int x,
y, dx, dy, xd, yd, sdx, sdy, ax, ay;
282 xd = ((src->
w - dst->
w) << 15);
283 yd = ((src->
h - dst->
h) << 15);
284 ax = (cx << 16) - (icos * cx);
285 ay = (cy << 16) - (isin * cx);
287 gap = dst->
pitch - dst->
w;
295 for (y = 0; y < dst->
h; y++) {
297 sdx = (ax + (isin * dy)) + xd;
298 sdy = (ay - (icos * dy)) + yd;
299 for (x = 0; x < dst->
w; x++) {
302 if ((
unsigned)dx < (unsigned)src->
w && (
unsigned)dy < (unsigned)src->
h) {
303 if (flipx) dx = (src->
w-1)-dx;
304 if (flipy) dy = (src->
h-1)-dy;
340 SDLgfx_rotateSurface(
SDL_Surface *
src,
double angle,
int centerx,
int centery,
int smooth,
int flipx,
int flipy,
int dstwidth,
int dstheight,
double cangle,
double sangle)
348 int colorKeyAvailable = 0;
349 double sangleinv, cangleinv;
361 colorKeyAvailable = 1;
375 0x000000ff, 0x0000ff00, 0x00ff0000, 0xff000000
377 0xff000000, 0x00ff0000, 0x0000ff00, 0x000000ff
391 sangleinv = sangle*65536.0;
392 cangleinv = cangle*65536.0;
418 rz_dst->
h = dstheight;
420 if (colorKeyAvailable == 1){
441 (
int) (sangleinv), (
int) (cangleinv),
461 (
int) (sangleinv), (
int) (cangleinv),
469 Uint8 alphaMod, cr, cg, cb;
#define SDL_ConvertSurfaceFormat
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
#define SDL_UnlockSurface
GLint GLint GLsizei width
uint32_t Uint32
An unsigned 32-bit integer type.
GLint GLint GLint GLint GLint x
SDL_BlendMode
The blend mode used in SDL_RenderCopy() and drawing operations.
#define SDL_MasksToPixelFormatEnum
A collection of pixels used in software blitting.
GLint GLint GLsizei GLsizei height
GLuint GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat t1
#define SDL_GetSurfaceBlendMode
static SDL_BlendMode blendMode
GLint GLint GLint GLint GLint GLint y
#define SDL_SetSurfaceColorMod
uint8_t Uint8
An unsigned 8-bit integer type.
static void transformSurfaceY(SDL_Surface *src, SDL_Surface *dst, int cx, int cy, int isin, int icos, int flipx, int flipy)
#define SDL_GetSurfaceAlphaMod
return Display return Display Bool Bool int int int return Display XEvent Bool(*) XPointer return Display return Display Drawable _Xconst char unsigned int unsigned int return Display Pixmap Pixmap XColor XColor unsigned int unsigned int return Display _Xconst char char int char return Display Visual unsigned int int int char unsigned int unsigned int in i)
#define SDL_CreateRGBSurface
#define SDL_GetSurfaceColorMod
#define SDL_SetSurfaceBlendMode
static Uint32 _colorkey(SDL_Surface *src)
SDL_Surface * SDLgfx_rotateSurface(SDL_Surface *src, double angle, int centerx, int centery, int smooth, int flipx, int flipy, int dstwidth, int dstheight, double cangle, double sangle)
void SDLgfx_rotozoomSurfaceSizeTrig(int width, int height, double angle, int *dstwidth, int *dstheight, double *cangle, double *sangle)
#define SDL_SetSurfaceAlphaMod
static void _transformSurfaceRGBA(SDL_Surface *src, SDL_Surface *dst, int cx, int cy, int isin, int icos, int flipx, int flipy, int smooth)