#include "../../SDL_internal.h"
#include <stdlib.h>
#include <string.h>
#include "SDL.h"
#include "SDL_rotate.h"
Go to the source code of this file.
|
static Uint32 | _colorkey (SDL_Surface *src) |
|
void | SDLgfx_rotozoomSurfaceSizeTrig (int width, int height, double angle, int *dstwidth, int *dstheight, double *cangle, double *sangle) |
|
static void | computeSourceIncrements90 (SDL_Surface *src, int bpp, int angle, int flipx, int flipy, int *sincx, int *sincy, int *signx, int *signy) |
|
static void | transformSurfaceRGBA90 (SDL_Surface *src, SDL_Surface *dst, int angle, int flipx, int flipy) |
|
static void | transformSurfaceY90 (SDL_Surface *src, SDL_Surface *dst, int angle, int flipx, int flipy) |
|
static void | _transformSurfaceRGBA (SDL_Surface *src, SDL_Surface *dst, int cx, int cy, int isin, int icos, int flipx, int flipy, int smooth) |
|
static void | transformSurfaceY (SDL_Surface *src, SDL_Surface *dst, int cx, int cy, int isin, int icos, int flipx, int flipy) |
|
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) |
|
◆ GUARD_ROWS
◆ MAX
#define MAX |
( |
|
a, |
|
|
|
b |
|
) |
| (((a) > (b)) ? (a) : (b)) |
◆ TRANSFORM_SURFACE_90
#define TRANSFORM_SURFACE_90 |
( |
|
pixelType | ) |
|
Value:int dy, dincy =
dst->pitch -
dst->w*
sizeof(pixelType), sincx, sincy, signx, signy; \
if (signx < 0) sp += (
src->
w-1)*sizeof(pixelType); \
if (signy < 0) sp += (
src->
h-1)*
src->pitch; \
\
for (dy = 0; dy <
dst->
h; sp += sincy, dp += dincy, dy++) { \
if (sincx == sizeof(pixelType)) { \
SDL_memcpy(dp, sp,
dst->w*
sizeof(pixelType)); \
sp +=
dst->w*
sizeof(pixelType); \
dp +=
dst->w*
sizeof(pixelType); \
} else { \
for (de = dp +
dst->w*
sizeof(pixelType); dp != de; sp += sincx, dp +=
sizeof(pixelType)) { \
*(pixelType*)dp = *(pixelType*)sp; \
} \
} \
}
Definition at line 176 of file SDL_rotate.c.
◆ _colorkey()
◆ _transformSurfaceRGBA()
static void _transformSurfaceRGBA |
( |
SDL_Surface * |
src, |
|
|
SDL_Surface * |
dst, |
|
|
int |
cx, |
|
|
int |
cy, |
|
|
int |
isin, |
|
|
int |
icos, |
|
|
int |
flipx, |
|
|
int |
flipy, |
|
|
int |
smooth |
|
) |
| |
|
static |
Definition at line 230 of file SDL_rotate.c.
232 int x,
y,
t1, t2, dx, dy, xd, yd, sdx, sdy, ax, ay, ex, ey, sw, sh;
240 xd = ((
src->w -
dst->w) << 15);
241 yd = ((
src->h -
dst->h) << 15);
242 ax = (cx << 16) - (icos * cx);
243 ay = (cy << 16) - (isin * cx);
247 gap =
dst->pitch -
dst->w * 4;
253 for (
y = 0;
y <
dst->h;
y++) {
255 sdx = (ax + (isin * dy)) + xd;
256 sdy = (ay - (icos * dy)) + yd;
257 for (
x = 0;
x <
dst->w;
x++) {
260 if (flipx) dx = sw - dx;
261 if (flipy) dy = sh - dy;
262 if ((dx > -1) && (dy > -1) && (dx < (
src->w-1)) && (dy < (
src->h-1))) {
267 sp += (
src->pitch/4);
272 cswap = c00; c00=c01; c01=cswap;
273 cswap = c10; c10=c11; c11=cswap;
276 cswap = c00; c00=c10; c10=cswap;
277 cswap = c01; c01=c11; c11=cswap;
284 t1 = ((((c01.
r - c00.
r) * ex) >> 16) + c00.
r) & 0xff;
285 t2 = ((((c11.
r - c10.
r) * ex) >> 16) + c10.
r) & 0xff;
286 pc->
r = (((t2 -
t1) * ey) >> 16) +
t1;
287 t1 = ((((c01.
g - c00.
g) * ex) >> 16) + c00.
g) & 0xff;
288 t2 = ((((c11.
g - c10.
g) * ex) >> 16) + c10.
g) & 0xff;
289 pc->
g = (((t2 -
t1) * ey) >> 16) +
t1;
290 t1 = ((((c01.
b - c00.
b) * ex) >> 16) + c00.
b) & 0xff;
291 t2 = ((((c11.
b - c10.
b) * ex) >> 16) + c10.
b) & 0xff;
292 pc->
b = (((t2 -
t1) * ey) >> 16) +
t1;
293 t1 = ((((c01.
a - c00.
a) * ex) >> 16) + c00.
a) & 0xff;
294 t2 = ((((c11.
a - c10.
a) * ex) >> 16) + c10.
a) & 0xff;
295 pc->
a = (((t2 -
t1) * ey) >> 16) +
t1;
304 for (
y = 0;
y <
dst->h;
y++) {
306 sdx = (ax + (isin * dy)) + xd;
307 sdy = (ay - (icos * dy)) + yd;
308 for (
x = 0;
x <
dst->w;
x++) {
311 if ((
unsigned)dx < (unsigned)
src->w && (
unsigned)dy < (unsigned)
src->h) {
312 if(flipx) dx = sw - dx;
313 if(flipy) dy = sh - dy;
References tColorRGBA::a, tColorRGBA::b, tColorRGBA::g, and tColorRGBA::r.
Referenced by SDLgfx_rotateSurface().
◆ computeSourceIncrements90()
static void computeSourceIncrements90 |
( |
SDL_Surface * |
src, |
|
|
int |
bpp, |
|
|
int |
angle, |
|
|
int |
flipx, |
|
|
int |
flipy, |
|
|
int * |
sincx, |
|
|
int * |
sincy, |
|
|
int * |
signx, |
|
|
int * |
signy |
|
) |
| |
|
static |
Definition at line 154 of file SDL_rotate.c.
157 int pitch = flipy ? -
src->pitch :
src->pitch;
162 case 0: *sincx = bpp; *sincy = pitch -
src->w * *sincx; *signx = *signy = 1;
break;
163 case 1: *sincx = -pitch; *sincy = bpp - *sincx *
src->h; *signx = 1; *signy = -1;
break;
164 case 2: *sincx = -bpp; *sincy = -
src->w * *sincx - pitch; *signx = *signy = -1;
break;
165 case 3:
default: *sincx = pitch; *sincy = -*sincx *
src->h - bpp; *signx = -1; *signy = 1;
break;
◆ SDLgfx_rotateSurface()
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 |
|
) |
| |
Definition at line 415 of file SDL_rotate.c.
423 double sangleinv, cangleinv;
436 is8bit =
src->format->BitsPerPixel == 8 && colorKeyAvailable;
437 if (!(is8bit || (
src->format->BitsPerPixel == 32 &&
src->format->Amask)))
441 sangleinv = sangle*65536.0;
442 cangleinv = cangle*65536.0;
449 if (rz_dst !=
NULL) {
450 for (
i = 0;
i <
src->format->palette->ncolors;
i++) {
458 src->format->Rmask,
src->format->Gmask,
459 src->format->Bmask,
src->format->Amask);
467 rz_dst->
h = dstheight;
471 if (colorKeyAvailable ==
SDL_TRUE) {
501 angle90 = (int)(
angle/90);
502 if (angle90 ==
angle/90) {
504 if (angle90 < 0) angle90 += 4;
523 flipx, flipy, smooth);
References _transformSurfaceRGBA(), SDL_Palette::colors, SDL_Surface::format, GUARD_ROWS, SDL_Surface::h, i, SDL_Palette::ncolors, NULL, SDL_PixelFormat::palette, SDL_BLENDMODE_BLEND, SDL_BLENDMODE_MOD, SDL_BLENDMODE_NONE, SDL_CreateRGBSurface, SDL_FALSE, SDL_FillRect, SDL_GetColorKey, SDL_GetSurfaceBlendMode, SDL_HasColorKey, SDL_LockSurface, SDL_MapRGBA, SDL_MUSTLOCK, SDL_SetColorKey, SDL_SetSurfaceBlendMode, SDL_TRUE, SDL_UnlockSurface, transformSurfaceRGBA90(), transformSurfaceY(), and transformSurfaceY90().
Referenced by SW_RenderCopyEx().
◆ SDLgfx_rotozoomSurfaceSizeTrig()
void SDLgfx_rotozoomSurfaceSizeTrig |
( |
int |
width, |
|
|
int |
height, |
|
|
double |
angle, |
|
|
int * |
dstwidth, |
|
|
int * |
dstheight, |
|
|
double * |
cangle, |
|
|
double * |
sangle |
|
) |
| |
Definition at line 106 of file SDL_rotate.c.
111 int angle90 = (int)(
angle/90);
112 if(angle90 ==
angle/90) {
114 if(angle90 < 0) angle90 += 4;
119 *sangle = angle90 == 1 ? -1 : 1;
123 *cangle = angle90 == 0 ? 1 : -1;
127 double x,
y, cx, cy, sx, sy;
129 int dstwidthhalf, dstheighthalf;
133 radangle =
angle * (M_PI / -180.0);
143 dstwidthhalf =
MAX((
int)
145 dstheighthalf =
MAX((
int)
147 *dstwidth = 2 * dstwidthhalf;
148 *dstheight = 2 * dstheighthalf;
References MAX, SDL_ceil, SDL_cos, SDL_fabs, and SDL_sin.
Referenced by SW_RenderCopyEx().
◆ transformSurfaceRGBA90()
◆ transformSurfaceY()
Definition at line 344 of file SDL_rotate.c.
346 int x,
y, dx, dy, xd, yd, sdx, sdy, ax, ay;
353 xd = ((
src->w -
dst->w) << 15);
354 yd = ((
src->h -
dst->h) << 15);
355 ax = (cx << 16) - (icos * cx);
356 ay = (cy << 16) - (isin * cx);
358 gap =
dst->pitch -
dst->w;
366 for (
y = 0;
y <
dst->h;
y++) {
368 sdx = (ax + (isin * dy)) + xd;
369 sdy = (ay - (icos * dy)) + yd;
370 for (
x = 0;
x <
dst->w;
x++) {
373 if ((
unsigned)dx < (unsigned)
src->w && (
unsigned)dy < (unsigned)
src->h) {
374 if (flipx) dx = (
src->w-1)-dx;
375 if (flipy) dy = (
src->h-1)-dy;
References _colorkey(), and SDL_memset.
Referenced by SDLgfx_rotateSurface().
◆ transformSurfaceY90()
#define SDL_UnlockSurface
GLuint GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat t1
A collection of pixels used in software blitting.
GLint GLint GLsizei width
static void transformSurfaceRGBA90(SDL_Surface *src, SDL_Surface *dst, int angle, int flipx, int flipy)
static void computeSourceIncrements90(SDL_Surface *src, int bpp, int angle, int flipx, int flipy, int *sincx, int *sincy, int *signx, int *signy)
GLfloat GLfloat GLfloat GLfloat h
#define SDL_GetSurfaceBlendMode
GLint GLint GLint GLint GLint x
GLint GLint GLsizei GLsizei height
static void _transformSurfaceRGBA(SDL_Surface *src, SDL_Surface *dst, int cx, int cy, int isin, int icos, int flipx, int flipy, int smooth)
static void transformSurfaceY(SDL_Surface *src, SDL_Surface *dst, int cx, int cy, int isin, int icos, int flipx, int flipy)
static Uint32 _colorkey(SDL_Surface *src)
SDL_BlendMode
The blend mode used in SDL_RenderCopy() and drawing operations.
GLint GLint GLint GLint GLint GLint y
#define SDL_CreateRGBSurface
static void transformSurfaceY90(SDL_Surface *src, SDL_Surface *dst, int angle, int flipx, int flipy)
#define TRANSFORM_SURFACE_90(pixelType)
#define SDL_SetSurfaceBlendMode
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)
GLubyte GLubyte GLubyte GLubyte w