61 #define MAX(a,b) (((a) > (b)) ? (a) : (b))
73 #define GUARD_ROWS (2)
78 #define VALUE_LIMIT 0.001
86 SDL_GetColorKey(src, &key);
108 int x, y, dx, dy, dgap, ra, ga, ba, aa;
118 n_average = factorx*factory;
126 dgap = dst->pitch - dst->w * 4;
128 for (y = 0; y < dst->h; y++) {
131 for (x = 0; x < dst->w; x++) {
136 for (dy=0; dy < factory; dy++) {
137 for (dx=0; dx < factorx; dx++) {
146 sp = (
tColorRGBA *)((Uint8*)sp + (src->pitch - 4*factorx));
151 sp = (
tColorRGBA *)((Uint8*)oosp + 4*factorx);
154 dp->
r = ra/n_average;
155 dp->
g = ga/n_average;
156 dp->
b = ba/n_average;
157 dp->
a = aa/n_average;
167 sp = (
tColorRGBA *)((Uint8*)osp + src->pitch*factory);
196 int x, y, dx, dy, dgap, a;
198 Uint8 *sp, *osp, *oosp;
206 n_average = factorx*factory;
211 sp = (Uint8 *) src->pixels;
213 dp = (Uint8 *) dst->pixels;
214 dgap = dst->pitch - dst->w;
216 for (y = 0; y < dst->h; y++) {
219 for (x = 0; x < dst->w; x++) {
224 for (dy=0; dy < factory; dy++) {
225 for (dx=0; dx < factorx; dx++) {
232 sp = (Uint8 *)((Uint8*)sp + (src->pitch - factorx));
237 sp = (Uint8 *)((Uint8*)oosp + factorx);
250 sp = (Uint8 *)((Uint8*)osp + src->pitch*factory);
255 dp = (Uint8 *)((Uint8 *)dp + dgap);
277 int _zoomSurfaceRGBA(SDL_Surface * src, SDL_Surface * dst,
int flipx,
int flipy,
int smooth)
279 int x, y, sx, sy, ssx, ssy, *sax, *say, *csax, *csay, *salast, csx, csy, ex, ey, cx, cy, sstep, sstepx, sstepy;
282 int spixelgap, spixelw, spixelh, dgap, t1, t2;
287 if ((sax = (
int *) malloc((dst->w + 1) *
sizeof(Uint32))) == NULL) {
290 if ((say = (
int *) malloc((dst->h + 1) *
sizeof(Uint32))) == NULL) {
298 spixelw = (src->w - 1);
299 spixelh = (src->h - 1);
301 sx = (int) (65536.0 * (
float) spixelw / (float) (dst->w - 1));
302 sy = (int) (65536.0 * (
float) spixelh / (float) (dst->h - 1));
304 sx = (int) (65536.0 * (
float) (src->w) / (
float) (dst->w));
305 sy = (int) (65536.0 * (
float) (src->h) / (
float) (dst->h));
309 ssx = (src->w << 16) - 1;
310 ssy = (src->h << 16) - 1;
315 for (x = 0; x <= dst->w; x++) {
329 for (y = 0; y <= dst->h; y++) {
342 dgap = dst->pitch - dst->w * 4;
343 spixelgap = src->pitch/4;
345 if (flipx) sp += spixelw;
346 if (flipy) sp += (spixelgap * spixelh);
357 for (y = 0; y < dst->h; y++) {
360 for (x = 0; x < dst->w; x++) {
364 ex = (*csax & 0xffff);
365 ey = (*csay & 0xffff);
368 sstepx = cx < spixelw;
369 sstepy = cy < spixelh;
394 t1 = ((((c01->
r - c00->
r) * ex) >> 16) + c00->
r) & 0xff;
395 t2 = ((((c11->
r - c10->
r) * ex) >> 16) + c10->
r) & 0xff;
396 dp->
r = (((t2 - t1) * ey) >> 16) + t1;
397 t1 = ((((c01->
g - c00->
g) * ex) >> 16) + c00->
g) & 0xff;
398 t2 = ((((c11->
g - c10->
g) * ex) >> 16) + c10->
g) & 0xff;
399 dp->
g = (((t2 - t1) * ey) >> 16) + t1;
400 t1 = ((((c01->
b - c00->
b) * ex) >> 16) + c00->
b) & 0xff;
401 t2 = ((((c11->
b - c10->
b) * ex) >> 16) + c10->
b) & 0xff;
402 dp->
b = (((t2 - t1) * ey) >> 16) + t1;
403 t1 = ((((c01->
a - c00->
a) * ex) >> 16) + c00->
a) & 0xff;
404 t2 = ((((c11->
a - c10->
a) * ex) >> 16) + c10->
a) & 0xff;
405 dp->
a = (((t2 - t1) * ey) >> 16) + t1;
411 sstep = (*csax >> 16) - (*salast >> 16);
428 sstep = (*csay >> 16) - (*salast >> 16);
446 for (y = 0; y < dst->h; y++) {
449 for (x = 0; x < dst->w; x++) {
460 sstep = (*csax >> 16) - (*salast >> 16);
461 if (flipx) sstep = -sstep;
474 sstep = (*csay >> 16) - (*salast >> 16);
476 if (flipy) sstep = -sstep;
510 int _zoomSurfaceY(SDL_Surface * src, SDL_Surface * dst,
int flipx,
int flipy)
513 Uint32 *sax, *say, *csax, *csay;
515 Uint8 *sp, *dp, *csp;
521 if ((sax = (Uint32 *) malloc((dst->w + 1) *
sizeof(Uint32))) == NULL) {
524 if ((say = (Uint32 *) malloc((dst->h + 1) *
sizeof(Uint32))) == NULL) {
532 sp = csp = (Uint8 *) src->pixels;
533 dp = (Uint8 *) dst->pixels;
534 dgap = dst->pitch - dst->w;
536 if (flipx) csp += (src->w-1);
537 if (flipy) csp = ( (Uint8*)csp + src->pitch*(src->h-1) );
544 for (x = 0; x < dst->w; x++) {
547 while (csx >= dst->w) {
551 (*csax) = (*csax) * (flipx ? -1 : 1);
556 for (y = 0; y < dst->h; y++) {
559 while (csy >= dst->h) {
563 (*csay) = (*csay) * (flipy ? -1 : 1);
571 for (y = 0; y < dst->h; y++) {
574 for (x = 0; x < dst->w; x++) {
592 csp += ((*csay) * src->pitch);
629 void _transformSurfaceRGBA(SDL_Surface * src, SDL_Surface * dst,
int cx,
int cy,
int isin,
int icos,
int flipx,
int flipy,
int smooth)
631 int x, y, t1, t2, dx, dy, xd, yd, sdx, sdy, ax, ay, ex, ey, sw, sh;
639 xd = ((src->w - dst->w) << 15);
640 yd = ((src->h - dst->h) << 15);
641 ax = (cx << 16) - (icos * cx);
642 ay = (cy << 16) - (isin * cx);
646 gap = dst->pitch - dst->w * 4;
652 for (y = 0; y < dst->h; y++) {
654 sdx = (ax + (isin * dy)) + xd;
655 sdy = (ay - (icos * dy)) + yd;
656 for (x = 0; x < dst->w; x++) {
659 if (flipx) dx = sw - dx;
660 if (flipy) dy = sh - dy;
661 if ((dx > -1) && (dy > -1) && (dx < (src->w-1)) && (dy < (src->h-1))) {
663 sp += ((src->pitch/4) * dy);
668 sp += (src->pitch/4);
673 cswap = c00; c00=c01; c01=cswap;
674 cswap = c10; c10=c11; c11=cswap;
677 cswap = c00; c00=c10; c10=cswap;
678 cswap = c01; c01=c11; c11=cswap;
685 t1 = ((((c01.
r - c00.
r) * ex) >> 16) + c00.
r) & 0xff;
686 t2 = ((((c11.
r - c10.
r) * ex) >> 16) + c10.
r) & 0xff;
687 pc->
r = (((t2 - t1) * ey) >> 16) + t1;
688 t1 = ((((c01.
g - c00.
g) * ex) >> 16) + c00.
g) & 0xff;
689 t2 = ((((c11.
g - c10.
g) * ex) >> 16) + c10.
g) & 0xff;
690 pc->
g = (((t2 - t1) * ey) >> 16) + t1;
691 t1 = ((((c01.
b - c00.
b) * ex) >> 16) + c00.
b) & 0xff;
692 t2 = ((((c11.
b - c10.
b) * ex) >> 16) + c10.
b) & 0xff;
693 pc->
b = (((t2 - t1) * ey) >> 16) + t1;
694 t1 = ((((c01.
a - c00.
a) * ex) >> 16) + c00.
a) & 0xff;
695 t2 = ((((c11.
a - c10.
a) * ex) >> 16) + c10.
a) & 0xff;
696 pc->
a = (((t2 - t1) * ey) >> 16) + t1;
705 for (y = 0; y < dst->h; y++) {
707 sdx = (ax + (isin * dy)) + xd;
708 sdy = (ay - (icos * dy)) + yd;
709 for (x = 0; x < dst->w; x++) {
710 dx = (short) (sdx >> 16);
711 dy = (short) (sdy >> 16);
712 if (flipx) dx = (src->w-1)-dx;
713 if (flipy) dy = (src->h-1)-dy;
714 if ((dx >= 0) && (dy >= 0) && (dx < src->w) && (dy < src->h)) {
715 sp = (
tColorRGBA *) ((Uint8 *) src->pixels + src->pitch * dy);
746 void transformSurfaceY(SDL_Surface * src, SDL_Surface * dst,
int cx,
int cy,
int isin,
int icos,
int flipx,
int flipy)
748 int x, y, dx, dy, xd, yd, sdx, sdy, ax, ay;
755 xd = ((src->w - dst->w) << 15);
756 yd = ((src->h - dst->h) << 15);
757 ax = (cx << 16) - (icos * cx);
758 ay = (cy << 16) - (isin * cx);
760 gap = dst->pitch - dst->w;
764 memset(pc, (
int)(
_colorkey(src) & 0xff), dst->pitch * dst->h);
768 for (y = 0; y < dst->h; y++) {
770 sdx = (ax + (isin * dy)) + xd;
771 sdy = (ay - (icos * dy)) + yd;
772 for (x = 0; x < dst->w; x++) {
773 dx = (short) (sdx >> 16);
774 dy = (short) (sdy >> 16);
775 if (flipx) dx = (src->w-1)-dx;
776 if (flipy) dy = (src->h-1)-dy;
777 if ((dx >= 0) && (dy >= 0) && (dx < src->w) && (dy < src->h)) {
778 sp = (
tColorY *) (src->pixels);
779 sp += (src->pitch * dy + dx);
805 int row, col, newWidth, newHeight;
812 if (!src || !src->format ||
813 !(src->format->BitsPerPixel == 8) ||
814 (src->format->BitsPerPixel == 16) ||
815 (src->format->BitsPerPixel == 24) ||
816 (src->format->BitsPerPixel == 32)) {
return NULL; }
819 while(numClockwiseTurns < 0) { numClockwiseTurns += 4; }
820 numClockwiseTurns = (numClockwiseTurns % 4);
823 newWidth = (numClockwiseTurns % 2) ? (src->h) : (src->w);
824 newHeight = (numClockwiseTurns % 2) ? (src->w) : (src->h);
825 dst = SDL_CreateRGBSurface( src->flags, newWidth, newHeight, src->format->BitsPerPixel,
834 if (SDL_MUSTLOCK(src)) {
835 SDL_LockSurface(src);
837 if (SDL_MUSTLOCK(dst)) {
838 SDL_LockSurface(dst);
842 bpp = src->format->BitsPerPixel / 8;
844 switch(numClockwiseTurns) {
850 if (src->pitch == dst->pitch) {
852 memcpy(dst->pixels, src->pixels, (src->h * src->pitch));
857 srcBuf = (Uint8*)(src->pixels);
858 dstBuf = (Uint8*)(dst->pixels);
859 for (row = 0; row < src->h; row++) {
860 memcpy(dstBuf, srcBuf, dst->w * bpp);
861 srcBuf += src->pitch;
862 dstBuf += dst->pitch;
871 for (row = 0; row < src->h; ++row) {
872 srcBuf = (Uint8*)(src->pixels) + (row * src->pitch);
873 dstBuf = (Uint8*)(dst->pixels) + (dst->w - row - 1) * bpp;
874 for (col = 0; col < src->w; ++col) {
875 memcpy (dstBuf, srcBuf, bpp);
877 dstBuf += dst->pitch;
885 for (row = 0; row < src->h; ++row) {
886 srcBuf = (Uint8*)(src->pixels) + (row * src->pitch);
887 dstBuf = (Uint8*)(dst->pixels) + ((dst->h - row - 1) * dst->pitch) + (dst->w - 1) * bpp;
888 for (col = 0; col < src->w; ++col) {
889 memcpy (dstBuf, srcBuf, bpp);
899 for (row = 0; row < src->h; ++row) {
900 srcBuf = (Uint8*)(src->pixels) + (row * src->pitch);
901 dstBuf = (Uint8*)(dst->pixels) + row + ((dst->h - 1) * dst->pitch);
902 for (col = 0; col < src->w; ++col) {
905 dstBuf -= dst->pitch;
913 if (SDL_MUSTLOCK(src)) {
914 SDL_UnlockSurface(src);
916 if (SDL_MUSTLOCK(dst)) {
917 SDL_UnlockSurface(dst);
939 int *dstwidth,
int *dstheight,
940 double *canglezoom,
double *sanglezoom)
942 double x, y, cx, cy, sx, sy;
944 int dstwidthhalf, dstheighthalf;
949 radangle = angle * (
M_PI / 180.0);
950 *sanglezoom = sin(radangle);
951 *canglezoom = cos(radangle);
952 *sanglezoom *= zoomx;
953 *canglezoom *= zoomx;
954 x = (double)(width / 2);
955 y = (double)(height / 2);
956 cx = *canglezoom * x;
957 cy = *canglezoom * y;
958 sx = *sanglezoom * x;
959 sy = *sanglezoom * y;
961 dstwidthhalf =
MAX((
int)
962 ceil(
MAX(
MAX(
MAX(fabs(cx + sy), fabs(cx - sy)), fabs(-cx + sy)), fabs(-cx - sy))), 1);
963 dstheighthalf =
MAX((
int)
964 ceil(
MAX(
MAX(
MAX(fabs(sx + cy), fabs(sx - cy)), fabs(-sx + cy)), fabs(-sx - cy))), 1);
965 *dstwidth = 2 * dstwidthhalf;
966 *dstheight = 2 * dstheighthalf;
980 void rotozoomSurfaceSizeXY(
int width,
int height,
double angle,
double zoomx,
double zoomy,
int *dstwidth,
int *dstheight)
982 double dummy_sanglezoom, dummy_canglezoom;
984 _rotozoomSurfaceSizeTrig(width, height, angle, zoomx, zoomy, dstwidth, dstheight, &dummy_sanglezoom, &dummy_canglezoom);
999 double dummy_sanglezoom, dummy_canglezoom;
1001 _rotozoomSurfaceSizeTrig(width, height, angle, zoom, zoom, dstwidth, dstheight, &dummy_sanglezoom, &dummy_canglezoom);
1040 SDL_Surface *
rotozoomSurfaceXY(SDL_Surface * src,
double angle,
double zoomx,
double zoomy,
int smooth)
1042 SDL_Surface *rz_src;
1043 SDL_Surface *rz_dst;
1045 double sanglezoom, canglezoom, sanglezoominv, canglezoominv;
1046 int dstwidthhalf, dstwidth, dstheighthalf, dstheight;
1048 int i, src_converted;
1061 is32bit = (src->format->BitsPerPixel == 32);
1062 if ((is32bit) || (src->format->BitsPerPixel == 8)) {
1073 SDL_CreateRGBSurface(SDL_SWSURFACE, src->w, src->h, 32,
1074 #
if SDL_BYTEORDER == SDL_LIL_ENDIAN
1075 0x000000ff, 0x0000ff00, 0x00ff0000, 0xff000000
1077 0xff000000, 0x00ff0000, 0x0000ff00, 0x000000ff
1081 SDL_BlitSurface(src, NULL, rz_src, NULL);
1090 flipx = (zoomx<0.0);
1091 if (flipx) zoomx=-zoomx;
1092 flipy = (zoomy<0.0);
1093 if (flipy) zoomy=-zoomy;
1096 zoominv = 65536.0 / (zoomx * zoomx);
1111 _rotozoomSurfaceSizeTrig(rz_src->w, rz_src->h, angle, zoomx, zoomy, &dstwidth, &dstheight, &canglezoom, &sanglezoom);
1116 sanglezoominv = sanglezoom;
1117 canglezoominv = canglezoom;
1118 sanglezoominv *= zoominv;
1119 canglezoominv *= zoominv;
1122 dstwidthhalf = dstwidth / 2;
1123 dstheighthalf = dstheight / 2;
1134 SDL_CreateRGBSurface(SDL_SWSURFACE, dstwidth, dstheight +
GUARD_ROWS, 32,
1135 rz_src->format->Rmask, rz_src->format->Gmask,
1136 rz_src->format->Bmask, rz_src->format->Amask);
1141 rz_dst = SDL_CreateRGBSurface(SDL_SWSURFACE, dstwidth, dstheight +
GUARD_ROWS, 8, 0, 0, 0, 0);
1149 rz_dst->h = dstheight;
1154 if (SDL_MUSTLOCK(rz_src)) {
1155 SDL_LockSurface(rz_src);
1166 (
int) (sanglezoominv), (
int) (canglezoominv),
1173 for (i = 0; i < rz_src->format->palette->ncolors; i++) {
1174 rz_dst->format->palette->colors[i] = rz_src->format->palette->colors[i];
1176 rz_dst->format->palette->ncolors = rz_src->format->palette->ncolors;
1181 (
int) (sanglezoominv), (
int) (canglezoominv),
1187 if (SDL_MUSTLOCK(rz_src)) {
1188 SDL_UnlockSurface(rz_src);
1203 zoomSurfaceSize(rz_src->w, rz_src->h, zoomx, zoomy, &dstwidth, &dstheight);
1214 SDL_CreateRGBSurface(SDL_SWSURFACE, dstwidth, dstheight +
GUARD_ROWS, 32,
1215 rz_src->format->Rmask, rz_src->format->Gmask,
1216 rz_src->format->Bmask, rz_src->format->Amask);
1221 rz_dst = SDL_CreateRGBSurface(SDL_SWSURFACE, dstwidth, dstheight +
GUARD_ROWS, 8, 0, 0, 0, 0);
1229 rz_dst->h = dstheight;
1234 if (SDL_MUSTLOCK(rz_src)) {
1235 SDL_LockSurface(rz_src);
1251 for (i = 0; i < rz_src->format->palette->ncolors; i++) {
1252 rz_dst->format->palette->colors[i] = rz_src->format->palette->colors[i];
1254 rz_dst->format->palette->ncolors = rz_src->format->palette->ncolors;
1265 if (SDL_MUSTLOCK(rz_src)) {
1266 SDL_UnlockSurface(rz_src);
1273 if (src_converted) {
1274 SDL_FreeSurface(rz_src);
1295 void zoomSurfaceSize(
int width,
int height,
double zoomx,
double zoomy,
int *dstwidth,
int *dstheight)
1301 flipx = (zoomx<0.0);
1302 if (flipx) zoomx = -zoomx;
1303 flipy = (zoomy<0.0);
1304 if (flipy) zoomy = -zoomy;
1319 *dstwidth = (int) floor(((
double) width * zoomx) + 0.5);
1320 *dstheight = (int) floor(((
double) height * zoomy) + 0.5);
1321 if (*dstwidth < 1) {
1324 if (*dstheight < 1) {
1345 SDL_Surface *
zoomSurface(SDL_Surface * src,
double zoomx,
double zoomy,
int smooth)
1347 SDL_Surface *rz_src;
1348 SDL_Surface *rz_dst;
1349 int dstwidth, dstheight;
1351 int i, src_converted;
1363 is32bit = (src->format->BitsPerPixel == 32);
1364 if ((is32bit) || (src->format->BitsPerPixel == 8)) {
1375 SDL_CreateRGBSurface(SDL_SWSURFACE, src->w, src->h, 32,
1376 #
if SDL_BYTEORDER == SDL_LIL_ENDIAN
1377 0x000000ff, 0x0000ff00, 0x00ff0000, 0xff000000
1379 0xff000000, 0x00ff0000, 0x0000ff00, 0x000000ff
1382 if (rz_src == NULL) {
1385 SDL_BlitSurface(src, NULL, rz_src, NULL);
1390 flipx = (zoomx<0.0);
1391 if (flipx) zoomx = -zoomx;
1392 flipy = (zoomy<0.0);
1393 if (flipy) zoomy = -zoomy;
1396 zoomSurfaceSize(rz_src->w, rz_src->h, zoomx, zoomy, &dstwidth, &dstheight);
1407 SDL_CreateRGBSurface(SDL_SWSURFACE, dstwidth, dstheight +
GUARD_ROWS, 32,
1408 rz_src->format->Rmask, rz_src->format->Gmask,
1409 rz_src->format->Bmask, rz_src->format->Amask);
1414 rz_dst = SDL_CreateRGBSurface(SDL_SWSURFACE, dstwidth, dstheight +
GUARD_ROWS, 8, 0, 0, 0, 0);
1418 if (rz_dst == NULL) {
1422 if (src_converted) {
1423 SDL_FreeSurface(rz_src);
1429 rz_dst->h = dstheight;
1434 if (SDL_MUSTLOCK(rz_src)) {
1435 SDL_LockSurface(rz_src);
1450 for (i = 0; i < rz_src->format->palette->ncolors; i++) {
1451 rz_dst->format->palette->colors[i] = rz_src->format->palette->colors[i];
1453 rz_dst->format->palette->ncolors = rz_src->format->palette->ncolors;
1462 if (SDL_MUSTLOCK(rz_src)) {
1463 SDL_UnlockSurface(rz_src);
1469 if (src_converted) {
1470 SDL_FreeSurface(rz_src);
1499 SDL_Surface *rz_src;
1500 SDL_Surface *rz_dst = NULL;
1501 int dstwidth, dstheight;
1503 int i, src_converted;
1516 is32bit = (src->format->BitsPerPixel == 32);
1517 if ((is32bit) || (src->format->BitsPerPixel == 8)) {
1527 rz_src = SDL_CreateRGBSurface(SDL_SWSURFACE, src->w, src->h, 32,
1528 #
if SDL_BYTEORDER == SDL_LIL_ENDIAN
1529 0x000000ff, 0x0000ff00, 0x00ff0000, 0xff000000
1531 0xff000000, 0x00ff0000, 0x0000ff00, 0x000000ff
1536 goto exitShrinkSurface;
1539 SDL_BlitSurface(src, NULL, rz_src, NULL);
1547 if (SDL_MUSTLOCK(rz_src)) {
1548 if (SDL_LockSurface(rz_src) < 0) {
1550 goto exitShrinkSurface;
1555 dstwidth=rz_src->w/factorx;
1556 while (dstwidth*factorx>rz_src->w) { dstwidth--; }
1557 dstheight=rz_src->h/factory;
1558 while (dstheight*factory>rz_src->h) { dstheight--; }
1569 SDL_CreateRGBSurface(SDL_SWSURFACE, dstwidth, dstheight +
GUARD_ROWS, 32,
1570 rz_src->format->Rmask, rz_src->format->Gmask,
1571 rz_src->format->Bmask, rz_src->format->Amask);
1576 rz_dst = SDL_CreateRGBSurface(SDL_SWSURFACE, dstwidth, dstheight +
GUARD_ROWS, 8, 0, 0, 0, 0);
1580 if (rz_dst == NULL) {
1582 goto exitShrinkSurface;
1586 rz_dst->h = dstheight;
1596 if ((result!=0) || (rz_dst==NULL)) {
1598 goto exitShrinkSurface;
1604 for (i = 0; i < rz_src->format->palette->ncolors; i++) {
1605 rz_dst->format->palette->colors[i] = rz_src->format->palette->colors[i];
1607 rz_dst->format->palette->ncolors = rz_src->format->palette->ncolors;
1614 goto exitShrinkSurface;
1623 if (SDL_MUSTLOCK(rz_src)) {
1624 SDL_UnlockSurface(rz_src);
1630 if (src_converted==1) {
1631 SDL_FreeSurface(rz_src);
1638 SDL_FreeSurface(rz_dst);
void transformSurfaceY(SDL_Surface *src, SDL_Surface *dst, int cx, int cy, int isin, int icos, int flipx, int flipy)
Rotates and zooms 8 bit palette/Y 'src' surface to 'dst' surface without smoothing.
SDL_Surface * rotozoomSurface(SDL_Surface *src, double angle, double zoom, int smooth)
Rotates and zooms a surface and optional anti-aliasing.
void rotozoomSurfaceSize(int width, int height, double angle, double zoom, int *dstwidth, int *dstheight)
Returns the size of the resulting target surface for a rotozoomSurface() call.
int _zoomSurfaceY(SDL_Surface *src, SDL_Surface *dst, int flipx, int flipy)
Internal 8 bit Zoomer without smoothing.
struct tColorY tColorY
A 8bit Y/palette pixel.
void rotozoomSurfaceSizeXY(int width, int height, double angle, double zoomx, double zoomy, int *dstwidth, int *dstheight)
Returns the size of the resulting target surface for a rotozoomSurfaceXY() call.
struct tColorRGBA tColorRGBA
A 32 bit RGBA pixel.
SDL_Surface * rotozoomSurfaceXY(SDL_Surface *src, double angle, double zoomx, double zoomy, int smooth)
Rotates and zooms a surface with different horizontal and vertival scaling factors and optional anti-...
Uint32 _colorkey(SDL_Surface *src)
Returns colorkey info for a surface.
int _shrinkSurfaceRGBA(SDL_Surface *src, SDL_Surface *dst, int factorx, int factory)
Internal 32 bit integer-factor averaging Shrinker.
int _zoomSurfaceRGBA(SDL_Surface *src, SDL_Surface *dst, int flipx, int flipy, int smooth)
Internal 32 bit Zoomer with optional anti-aliasing by bilinear interpolation.
SDL_Surface * zoomSurface(SDL_Surface *src, double zoomx, double zoomy, int smooth)
Zoom a surface by independent horizontal and vertical factors with optional smoothing.
void zoomSurfaceSize(int width, int height, double zoomx, double zoomy, int *dstwidth, int *dstheight)
Calculates the size of the target surface for a zoomSurface() call.
#define GUARD_ROWS
Number of guard rows added to destination surfaces.
#define MAX(a, b)
Returns maximum of two numbers a and b.
void _rotozoomSurfaceSizeTrig(int width, int height, double angle, double zoomx, double zoomy, int *dstwidth, int *dstheight, double *canglezoom, double *sanglezoom)
Internal target surface sizing function for rotozooms with trig result return.
void _transformSurfaceRGBA(SDL_Surface *src, SDL_Surface *dst, int cx, int cy, int isin, int icos, int flipx, int flipy, int smooth)
Internal 32 bit rotozoomer with optional anti-aliasing.
#define VALUE_LIMIT
Lower limit of absolute zoom factor or rotation degrees.
int _shrinkSurfaceY(SDL_Surface *src, SDL_Surface *dst, int factorx, int factory)
Internal 8 bit integer-factor averaging shrinker.
SDL_Surface * shrinkSurface(SDL_Surface *src, int factorx, int factory)
Shrink a surface by an integer ratio using averaging.
SDL_Surface * rotateSurface90Degrees(SDL_Surface *src, int numClockwiseTurns)
Rotates a 8/16/24/32 bit surface in increments of 90 degrees.