67 #define MAX(a,b) (((a) > (b)) ? (a) : (b))
79 #define GUARD_ROWS (2)
84 #define VALUE_LIMIT 0.001
92 SDL_GetColorKey(src, &key);
117 int x,
y, dx, dy, dgap, ra, ga, ba, aa;
127 n_average = factorx*factory;
135 dgap = dst->pitch - dst->w * 4;
137 for (
y = 0;
y < dst->h;
y++)
140 for (
x = 0;
x < dst->w;
x++)
145 for (dy=0; dy < factory; dy++)
147 for (dx=0; dx < factorx; dx++)
158 reinterpret_cast<Uint8*
>(sp) +
159 (src->pitch - 4*factorx));
165 reinterpret_cast<Uint8*
>(oosp) + 4*factorx);
168 dp->
r = ra/n_average;
169 dp->
g = ga/n_average;
170 dp->
b = ba/n_average;
171 dp->
a = aa/n_average;
181 sp =
reinterpret_cast<tColorRGBA *
>(
reinterpret_cast<Uint8*
>(osp) +
187 dp =
reinterpret_cast<tColorRGBA *
>(
reinterpret_cast<Uint8*
>(dp) +
215 int x,
y, dx, dy, dgap, a;
217 Uint8 *sp, *osp, *oosp;
225 n_average = factorx*factory;
230 sp =
static_cast<Uint8*
>(src->pixels);
232 dp =
static_cast<Uint8*
>(dst->pixels);
233 dgap = dst->pitch - dst->w;
235 for (
y = 0;
y < dst->h;
y++)
238 for (
x = 0;
x < dst->w;
x++)
243 for (dy=0; dy < factory; dy++)
245 for (dx=0; dx < factorx; dx++)
253 sp =
static_cast<Uint8*
>(
static_cast<Uint8*
>(sp) +
254 (src->pitch - factorx));
259 sp =
static_cast<Uint8*
>(
static_cast<Uint8*
>(oosp) + factorx);
272 sp =
static_cast<Uint8*
>(
static_cast<Uint8*
>(osp) +
278 dp =
static_cast<Uint8*
>(
static_cast<Uint8*
>(dp) + dgap);
306 int x,
y, sx, sy, ssx, ssy;
307 int *sax, *say, *csax, *csay, *salast;
308 int csx, csy, ex, ey, cx, cy, sstep, sstepx, sstepy;
311 int spixelgap, spixelw, spixelh, dgap, t1, t2;
316 if ((sax =
static_cast<int *
>(malloc((dst->w + 1) *
sizeof(Uint32)))) ==
nullptr)
320 if ((say =
static_cast<int *
>(malloc((dst->h + 1) *
sizeof(Uint32)))) ==
nullptr)
329 spixelw = (src->w - 1);
330 spixelh = (src->h - 1);
333 sx =
static_cast<int>(65536.0 *
static_cast<float>(spixelw) /
334 static_cast<float>(dst->w - 1));
335 sy =
static_cast<int>(65536.0 *
static_cast<float>(spixelh) /
336 static_cast<float>(dst->h - 1));
340 sx =
static_cast<int>(65536.0 *
static_cast<float>(src->w) /
341 static_cast<float>(dst->w));
342 sy =
static_cast<int>(65536.0 *
static_cast<float>(src->h) /
343 static_cast<float>(dst->h));
347 ssx = (src->w << 16) - 1;
348 ssy = (src->h << 16) - 1;
353 for (
x = 0;
x <= dst->w;
x++)
369 for (
y = 0;
y <= dst->h;
y++)
384 dgap = dst->pitch - dst->w * 4;
385 spixelgap = src->pitch/4;
387 if (flipx) sp += spixelw;
388 if (flipy) sp += (spixelgap * spixelh);
399 for (
y = 0;
y < dst->h;
y++)
403 for (
x = 0;
x < dst->w;
x++)
408 ex = (*csax & 0xffff);
409 ey = (*csay & 0xffff);
412 sstepx = cx < spixelw;
413 sstepy = cy < spixelh;
446 t1 = ((((c01->
r - c00->
r) * ex) >> 16) + c00->
r) & 0xff;
447 t2 = ((((c11->
r - c10->
r) * ex) >> 16) + c10->
r) & 0xff;
448 dp->
r = (((t2 - t1) * ey) >> 16) + t1;
449 t1 = ((((c01->
g - c00->
g) * ex) >> 16) + c00->
g) & 0xff;
450 t2 = ((((c11->
g - c10->
g) * ex) >> 16) + c10->
g) & 0xff;
451 dp->
g = (((t2 - t1) * ey) >> 16) + t1;
452 t1 = ((((c01->
b - c00->
b) * ex) >> 16) + c00->
b) & 0xff;
453 t2 = ((((c11->
b - c10->
b) * ex) >> 16) + c10->
b) & 0xff;
454 dp->
b = (((t2 - t1) * ey) >> 16) + t1;
455 t1 = ((((c01->
a - c00->
a) * ex) >> 16) + c00->
a) & 0xff;
456 t2 = ((((c11->
a - c10->
a) * ex) >> 16) + c10->
a) & 0xff;
457 dp->
a = (((t2 - t1) * ey) >> 16) + t1;
463 sstep = (*csax >> 16) - (*salast >> 16);
483 sstep = (*csay >> 16) - (*salast >> 16);
498 reinterpret_cast<Uint8*
>(dp) + dgap);
507 for (
y = 0;
y < dst->h;
y++)
511 for (
x = 0;
x < dst->w;
x++)
523 sstep = (*csax >> 16) - (*salast >> 16);
524 if (flipx) sstep = -sstep;
537 sstep = (*csay >> 16) - (*salast >> 16);
539 if (flipy) sstep = -sstep;
546 reinterpret_cast<Uint8*
>(dp) + dgap);
580 Uint32 *sax, *say, *csax, *csay;
582 Uint8 *sp, *dp, *csp;
588 if ((sax =
static_cast<Uint32 *
>(malloc((dst->w + 1) *
589 sizeof(Uint32)))) ==
nullptr)
593 if ((say =
static_cast<Uint32 *
>(malloc((dst->h + 1) *
594 sizeof(Uint32)))) ==
nullptr)
603 sp = csp =
static_cast<Uint8*
>(src->pixels);
604 dp =
static_cast<Uint8*
>(dst->pixels);
605 dgap = dst->pitch - dst->w;
607 if (flipx) csp += (src->w-1);
608 if (flipy) csp = (
static_cast<Uint8*
>(csp) + src->pitch*(src->h-1));
615 for (
x = 0;
x < dst->w;
x++)
619 while (csx >= dst->w)
624 (*csax) = (*csax) * (flipx ? -1 : 1);
629 for (
y = 0;
y < dst->h;
y++)
633 while (csy >= dst->h)
638 (*csay) = (*csay) * (flipy ? -1 : 1);
646 for (
y = 0;
y < dst->h;
y++)
650 for (
x = 0;
x < dst->w;
x++)
669 csp += ((*csay) * src->pitch);
716 int x,
y, t1, t2, dx, dy, xd, yd, sdx, sdy, ax, ay, ex, ey, sw, sh;
724 xd = ((src->w - dst->w) << 15);
725 yd = ((src->h - dst->h) << 15);
726 ax = (cx << 16) - (icos * cx);
727 ay = (cy << 16) - (isin * cx);
731 gap = dst->pitch - dst->w * 4;
738 for (
y = 0;
y < dst->h;
y++)
741 sdx = (ax + (isin * dy)) + xd;
742 sdy = (ay - (icos * dy)) + yd;
743 for (
x = 0;
x < dst->w;
x++)
747 if (flipx) dx = sw - dx;
748 if (flipy) dy = sh - dy;
749 if ((dx > -1) && (dy > -1) &&
750 (dx < (src->w-1)) && (dy < (src->h-1)))
753 sp += ((src->pitch/4) * dy);
758 sp += (src->pitch/4);
764 cswap = c00; c00=c01; c01=cswap;
765 cswap = c10; c10=c11; c11=cswap;
769 cswap = c00; c00=c10; c10=cswap;
770 cswap = c01; c01=c11; c11=cswap;
777 t1 = ((((c01.
r - c00.
r) * ex) >> 16) + c00.
r) & 0xff;
778 t2 = ((((c11.
r - c10.
r) * ex) >> 16) + c10.
r) & 0xff;
779 pc->
r = (((t2 - t1) * ey) >> 16) + t1;
780 t1 = ((((c01.
g - c00.
g) * ex) >> 16) + c00.
g) & 0xff;
781 t2 = ((((c11.
g - c10.
g) * ex) >> 16) + c10.
g) & 0xff;
782 pc->
g = (((t2 - t1) * ey) >> 16) + t1;
783 t1 = ((((c01.
b - c00.
b) * ex) >> 16) + c00.
b) & 0xff;
784 t2 = ((((c11.
b - c10.
b) * ex) >> 16) + c10.
b) & 0xff;
785 pc->
b = (((t2 - t1) * ey) >> 16) + t1;
786 t1 = ((((c01.
a - c00.
a) * ex) >> 16) + c00.
a) & 0xff;
787 t2 = ((((c11.
a - c10.
a) * ex) >> 16) + c10.
a) & 0xff;
788 pc->
a = (((t2 - t1) * ey) >> 16) + t1;
795 reinterpret_cast<Uint8*
>(pc) + gap);
800 for (
y = 0;
y < dst->h;
y++)
803 sdx = (ax + (isin * dy)) + xd;
804 sdy = (ay - (icos * dy)) + yd;
805 for (
x = 0;
x < dst->w;
x++)
807 dx =
static_cast<short>(sdx >> 16);
808 dy =
static_cast<short>(sdy >> 16);
809 if (flipx) dx = (src->w-1)-dx;
810 if (flipy) dy = (src->h-1)-dy;
811 if ((dx >= 0) && (dy >= 0) && (dx < src->w) && (dy < src->h))
814 reinterpret_cast<Uint8*
>(src->pixels) +
824 reinterpret_cast<Uint8*
>(pc) + gap);
856 int x,
y, dx, dy, xd, yd, sdx, sdy, ax, ay;
863 xd = ((src->w - dst->w) << 15);
864 yd = ((src->h - dst->h) << 15);
865 ax = (cx << 16) - (icos * cx);
866 ay = (cy << 16) - (isin * cx);
867 pc =
static_cast<tColorY*
>(dst->pixels);
868 gap = dst->pitch - dst->w;
872 memset(pc,
static_cast<int>(
_colorkey(src) & 0xff), dst->pitch * dst->h);
876 for (
y = 0;
y < dst->h;
y++)
879 sdx = (ax + (isin * dy)) + xd;
880 sdy = (ay - (icos * dy)) + yd;
881 for (
x = 0;
x < dst->w;
x++)
883 dx =
static_cast<short>(sdx >> 16);
884 dy =
static_cast<short>(sdy >> 16);
885 if (flipx) dx = (src->w-1)-dx;
886 if (flipy) dy = (src->h-1)-dy;
887 if ((dx >= 0) && (dy >= 0) && (dx < src->w) && (dy < src->h))
889 sp =
static_cast<tColorY *
>(src->pixels);
890 sp += (src->pitch * dy + dx);
915 int numClockwiseTurns)
917 int row, col, newWidth, newHeight;
922 int normalizedClockwiseTurns;
928 SDL_SetError(
"NULL source surface or source surface format");
932 if ((src->format->BitsPerPixel % 8) != 0)
934 SDL_SetError(
"Invalid source surface bit depth");
939 normalizedClockwiseTurns = (numClockwiseTurns % 4);
940 if (normalizedClockwiseTurns < 0)
942 normalizedClockwiseTurns += 4;
946 if (normalizedClockwiseTurns % 2)
957 dst = SDL_CreateRGBSurface(src->flags,
960 src->format->BitsPerPixel,
967 SDL_SetError(
"Could not create destination surface");
971 if (SDL_MUSTLOCK(src))
973 SDL_LockSurface(src);
975 if (SDL_MUSTLOCK(dst))
977 SDL_LockSurface(dst);
981 bpp = src->format->BitsPerPixel / 8;
983 switch (normalizedClockwiseTurns)
991 if (src->pitch == dst->pitch)
995 memcpy(dst->pixels, src->pixels, (src->h * src->pitch));
1000 srcBuf =
static_cast<Uint8*
>(src->pixels);
1001 dstBuf =
static_cast<Uint8*
>(dst->pixels);
1003 for (row = 0; row < src->h; row++)
1005 memcpy(dstBuf, srcBuf, bpr);
1006 srcBuf += src->pitch;
1007 dstBuf += dst->pitch;
1016 for (row = 0; row < src->h; ++row)
1018 srcBuf =
static_cast<Uint8*
>(src->pixels) +
1020 dstBuf =
static_cast<Uint8*
>(dst->pixels) +
1021 (dst->w - row - 1) * bpp;
1022 for (col = 0; col < src->w; ++col)
1024 memcpy (dstBuf, srcBuf, bpp);
1026 dstBuf += dst->pitch;
1034 for (row = 0; row < src->h; ++row)
1036 srcBuf =
static_cast<Uint8*
>(src->pixels) +
1038 dstBuf =
static_cast<Uint8*
>(dst->pixels) +
1039 ((dst->h - row - 1) * dst->pitch) + (dst->w - 1) * bpp;
1040 for (col = 0; col < src->w; ++col)
1042 memcpy (dstBuf, srcBuf, bpp);
1052 for (row = 0; row < src->h; ++row)
1054 srcBuf =
static_cast<Uint8*
>(src->pixels) + (row * src->pitch);
1055 dstBuf =
static_cast<Uint8*
>(dst->pixels) +
1056 (row * bpp) + (dst->h * dst->pitch);
1057 for (col = 0; col < src->w; ++col)
1059 memcpy (dstBuf, srcBuf, bpp);
1061 dstBuf -= dst->pitch;
1071 if (SDL_MUSTLOCK(src))
1073 SDL_UnlockSurface(src);
1075 if (SDL_MUSTLOCK(dst))
1077 SDL_UnlockSurface(dst);
1109 double x,
y, cx, cy, sx, sy;
1111 int dstwidthhalf, dstheighthalf;
1116 radangle = angle * (M_PI / 180.0);
1117 *sanglezoom = sin(radangle);
1118 *canglezoom = cos(radangle);
1119 *sanglezoom *= zoomx;
1120 *canglezoom *= zoomy;
1121 x =
static_cast<double>(width / 2);
1122 y =
static_cast<double>(height / 2);
1123 cx = *canglezoom *
x;
1124 cy = *canglezoom *
y;
1125 sx = *sanglezoom *
x;
1126 sy = *sanglezoom *
y;
1128 dstwidthhalf =
MAX(
static_cast<int>(
1129 ceil(
MAX(
MAX(
MAX(fabs(cx + sy), fabs(cx - sy)),
1130 fabs(-cx + sy)), fabs(-cx - sy)))), 1);
1131 dstheighthalf =
MAX(
static_cast<int>(
1132 ceil(
MAX(
MAX(
MAX(fabs(sx + cy), fabs(sx - cy)),
1133 fabs(-sx + cy)), fabs(-sx - cy)))), 1);
1134 *dstwidth = 2 * dstwidthhalf;
1135 *dstheight = 2 * dstheighthalf;
1158 double dummy_sanglezoom, dummy_canglezoom;
1161 dstwidth, dstheight, &dummy_sanglezoom, &dummy_canglezoom);
1182 double dummy_sanglezoom, dummy_canglezoom;
1185 dstwidth, dstheight, &dummy_sanglezoom, &dummy_canglezoom);
1236 SDL_Surface *rz_src;
1237 SDL_Surface *rz_dst;
1239 double sanglezoom, canglezoom, sanglezoominv, canglezoominv;
1240 int dstwidthhalf, dstwidth, dstheighthalf, dstheight;
1242 int i, src_converted;
1256 is32bit = (src->format->BitsPerPixel == 32);
1257 if ((is32bit) || (src->format->BitsPerPixel == 8))
1271 SDL_CreateRGBSurface(SDL_SWSURFACE, src->w, src->h, 32,
1272 #
if SDL_BYTEORDER == SDL_LIL_ENDIAN
1273 0x000000ff, 0x0000ff00, 0x00ff0000, 0xff000000
1275 0xff000000, 0x00ff0000, 0x0000ff00, 0x000000ff
1279 SDL_BlitSurface(src,
nullptr, rz_src,
nullptr);
1288 flipx = (zoomx<0.0);
1289 if (flipx) zoomx=-zoomx;
1290 flipy = (zoomy<0.0);
1291 if (flipy) zoomy=-zoomy;
1294 zoominv = 65536.0 / (zoomx * zoomx);
1311 &dstwidth, &dstheight, &canglezoom, &sanglezoom);
1316 sanglezoominv = sanglezoom;
1317 canglezoominv = canglezoom;
1318 sanglezoominv *= zoominv;
1319 canglezoominv *= zoominv;
1322 dstwidthhalf = dstwidth / 2;
1323 dstheighthalf = dstheight / 2;
1335 SDL_CreateRGBSurface(SDL_SWSURFACE,
1337 rz_src->format->Rmask, rz_src->format->Gmask,
1338 rz_src->format->Bmask, rz_src->format->Amask);
1345 rz_dst = SDL_CreateRGBSurface(SDL_SWSURFACE, dstwidth,
1350 if (rz_dst ==
nullptr)
1354 rz_dst->h = dstheight;
1359 if (SDL_MUSTLOCK(rz_src))
1361 SDL_LockSurface(rz_src);
1374 static_cast<int>(sanglezoominv),
1375 static_cast<int>(canglezoominv),
1384 for (i = 0; i < rz_src->format->palette->ncolors; i++)
1386 rz_dst->format->palette->colors[i] =
1387 rz_src->format->palette->colors[i];
1389 rz_dst->format->palette->ncolors =
1390 rz_src->format->palette->ncolors;
1395 static_cast<int>(sanglezoominv),
1396 static_cast<int>(canglezoominv),
1402 if (SDL_MUSTLOCK(rz_src))
1404 SDL_UnlockSurface(rz_src);
1421 &dstwidth, &dstheight);
1433 SDL_CreateRGBSurface(SDL_SWSURFACE,
1435 rz_src->format->Rmask, rz_src->format->Gmask,
1436 rz_src->format->Bmask, rz_src->format->Amask);
1443 rz_dst = SDL_CreateRGBSurface(SDL_SWSURFACE,
1444 dstwidth, dstheight +
GUARD_ROWS, 8, 0, 0, 0, 0);
1448 if (rz_dst ==
nullptr)
1452 rz_dst->h = dstheight;
1457 if (SDL_MUSTLOCK(rz_src))
1459 SDL_LockSurface(rz_src);
1479 for (i = 0; i < rz_src->format->palette->ncolors; i++)
1481 rz_dst->format->palette->colors[i] =
1482 rz_src->format->palette->colors[i];
1484 rz_dst->format->palette->ncolors =
1485 rz_src->format->palette->ncolors;
1496 if (SDL_MUSTLOCK(rz_src))
1498 SDL_UnlockSurface(rz_src);
1507 SDL_FreeSurface(rz_src);
1532 double zoomx,
double zoomy,
1533 int *dstwidth,
int *dstheight)
1539 flipx = (zoomx<0.0);
1540 if (flipx) zoomx = -zoomx;
1541 flipy = (zoomy<0.0);
1542 if (flipy) zoomy = -zoomy;
1559 *dstwidth =
static_cast<int>(floor((
static_cast<double>(
1560 width) * zoomx) + 0.5));
1561 *dstheight =
static_cast<int>(floor((
static_cast<double>(
1562 height) * zoomy) + 0.5));
1595 SDL_Surface *rz_src;
1596 SDL_Surface *rz_dst;
1597 int dstwidth, dstheight;
1599 int i, src_converted;
1611 is32bit = (src->format->BitsPerPixel == 32);
1612 if ((is32bit) || (src->format->BitsPerPixel == 8))
1626 SDL_CreateRGBSurface(SDL_SWSURFACE, src->w, src->h, 32,
1627 #
if SDL_BYTEORDER == SDL_LIL_ENDIAN
1628 0x000000ff, 0x0000ff00, 0x00ff0000, 0xff000000
1630 0xff000000, 0x00ff0000, 0x0000ff00, 0x000000ff
1633 if (rz_src ==
nullptr)
1637 SDL_BlitSurface(src,
nullptr, rz_src,
nullptr);
1642 flipx = (zoomx<0.0);
1643 if (flipx) zoomx = -zoomx;
1644 flipy = (zoomy<0.0);
1645 if (flipy) zoomy = -zoomy;
1648 zoomSurfaceSize(rz_src->w, rz_src->h, zoomx, zoomy, &dstwidth, &dstheight);
1659 rz_dst = SDL_CreateRGBSurface(SDL_SWSURFACE,
1661 rz_src->format->Rmask, rz_src->format->Gmask,
1662 rz_src->format->Bmask, rz_src->format->Amask);
1669 rz_dst = SDL_CreateRGBSurface(SDL_SWSURFACE,
1670 dstwidth, dstheight +
GUARD_ROWS, 8, 0, 0, 0, 0);
1674 if (rz_dst ==
nullptr)
1681 SDL_FreeSurface(rz_src);
1687 rz_dst->h = dstheight;
1692 if (SDL_MUSTLOCK(rz_src))
1694 SDL_LockSurface(rz_src);
1712 for (i = 0; i < rz_src->format->palette->ncolors; i++)
1714 rz_dst->format->palette->colors[i] =
1715 rz_src->format->palette->colors[i];
1717 rz_dst->format->palette->ncolors = rz_src->format->palette->ncolors;
1726 if (SDL_MUSTLOCK(rz_src))
1728 SDL_UnlockSurface(rz_src);
1736 SDL_FreeSurface(rz_src);
1767 SDL_Surface *rz_src;
1768 SDL_Surface *rz_dst =
nullptr;
1769 int dstwidth, dstheight;
1771 int i, src_converted = 0;
1785 is32bit = (src->format->BitsPerPixel == 32);
1786 if ((is32bit) || (src->format->BitsPerPixel == 8))
1799 rz_src = SDL_CreateRGBSurface(SDL_SWSURFACE, src->w, src->h, 32,
1800 #
if SDL_BYTEORDER == SDL_LIL_ENDIAN
1801 0x000000ff, 0x0000ff00, 0x00ff0000, 0xff000000
1803 0xff000000, 0x00ff0000, 0x0000ff00, 0x000000ff
1806 if (rz_src==
nullptr)
1809 goto exitShrinkSurface;
1812 SDL_BlitSurface(src,
nullptr, rz_src,
nullptr);
1820 if (SDL_MUSTLOCK(rz_src))
1822 if (SDL_LockSurface(rz_src) < 0)
1825 goto exitShrinkSurface;
1830 dstwidth=rz_src->w/factorx;
1831 while (dstwidth*factorx>rz_src->w)
1835 dstheight=rz_src->h/factory;
1836 while (dstheight*factory>rz_src->h)
1850 rz_dst = SDL_CreateRGBSurface(
1851 SDL_SWSURFACE, dstwidth, dstheight +
GUARD_ROWS, 32,
1852 rz_src->format->Rmask, rz_src->format->Gmask,
1853 rz_src->format->Bmask, rz_src->format->Amask);
1860 rz_dst = SDL_CreateRGBSurface(SDL_SWSURFACE,
1861 dstwidth, dstheight +
GUARD_ROWS, 8, 0, 0, 0, 0);
1865 if (rz_dst ==
nullptr)
1868 goto exitShrinkSurface;
1872 rz_dst->h = dstheight;
1883 if ((result!=0) || (rz_dst==
nullptr))
1886 goto exitShrinkSurface;
1894 for (i = 0; i < rz_src->format->palette->ncolors; i++)
1896 rz_dst->format->palette->colors[i] = rz_src->format->palette->colors[i];
1898 rz_dst->format->palette->ncolors = rz_src->format->palette->ncolors;
1906 goto exitShrinkSurface;
1911 if (rz_src!=
nullptr)
1916 if (SDL_MUSTLOCK(rz_src))
1918 SDL_UnlockSurface(rz_src);
1924 if (src_converted==1)
1926 SDL_FreeSurface(rz_src);
1933 if (rz_dst!=
nullptr)
1935 SDL_FreeSurface(rz_dst);
#define GUARD_ROWS
Number of guard rows added to destination surfaces.
static 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.
static Uint32 _colorkey(SDL_Surface *src)
Returns colorkey info for a surface.
static int _shrinkSurfaceY(SDL_Surface *src, SDL_Surface *dst, int factorx, int factory)
Internal 8 bit integer-factor averaging shrinker.
static 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.
struct tColorRGBA tColorRGBA
A 32 bit RGBA pixel.
static int _shrinkSurfaceRGBA(SDL_Surface *src, SDL_Surface *dst, int factorx, int factory)
Internal 32 bit integer-factor averaging Shrinker.
SDL_Surface * rotozoomSurface(SDL_Surface *src, double angle, double zoom, int smooth)
Rotates and zooms a surface and optional anti-aliasing.
SDL_Surface * rotateSurface90Degrees(SDL_Surface *src, int numClockwiseTurns)
Rotates a 8/16/24/32 bit surface in increments of 90 degrees.
static int _zoomSurfaceY(SDL_Surface *src, SDL_Surface *dst, int flipx, int flipy)
Internal 8 bit Zoomer without 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.
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.
#define VALUE_LIMIT
Lower limit of absolute zoom factor or rotation degrees.
static 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.
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-...
SDL_Surface * shrinkSurface(SDL_Surface *src, int factorx, int factory)
Shrink a surface by an integer ratio using averaging.
static 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 * zoomSurface(SDL_Surface *src, double zoomx, double zoomy, int smooth)
Zoom a surface by independent horizontal and vertical factors with optional 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.
#define MAX(a, b)
Returns maximum of two numbers a and b.