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;
 
  810         int normalizedClockwiseTurns;
 
  815                 SDL_SetError(
"NULL source surface or source surface format");
 
  819         if ((src->format->BitsPerPixel % 8) != 0) {
 
  820                 SDL_SetError(
"Invalid source surface bit depth");
 
  825         normalizedClockwiseTurns = (numClockwiseTurns % 4);
 
  826         if (normalizedClockwiseTurns < 0) {
 
  827                 normalizedClockwiseTurns += 4;
 
  831         if (normalizedClockwiseTurns % 2) {
 
  839         dst = SDL_CreateRGBSurface( src->flags, newWidth, newHeight, src->format->BitsPerPixel,
 
  845                 SDL_SetError(
"Could not create destination surface"); 
 
  849         if (SDL_MUSTLOCK(src)) {
 
  850                 SDL_LockSurface(src);
 
  852         if (SDL_MUSTLOCK(dst)) {
 
  853                 SDL_LockSurface(dst);
 
  857         bpp = src->format->BitsPerPixel / 8;
 
  859         switch(normalizedClockwiseTurns) {
 
  865                         if (src->pitch == dst->pitch) {
 
  867                                 memcpy(dst->pixels, src->pixels, (src->h * src->pitch));
 
  872                                 srcBuf = (Uint8*)(src->pixels);
 
  873                                 dstBuf = (Uint8*)(dst->pixels);
 
  875                                 for (row = 0; row < src->h; row++) {
 
  876                                         memcpy(dstBuf, srcBuf, bpr);
 
  877                                         srcBuf += src->pitch;
 
  878                                         dstBuf += dst->pitch;
 
  887                         for (row = 0; row < src->h; ++row) {
 
  888                                 srcBuf = (Uint8*)(src->pixels) + (row * src->pitch);
 
  889                                 dstBuf = (Uint8*)(dst->pixels) + (dst->w - row - 1) * bpp;
 
  890                                 for (col = 0; col < src->w; ++col) {
 
  891                                         memcpy (dstBuf, srcBuf, bpp);
 
  893                                         dstBuf += dst->pitch;
 
  901                         for (row = 0; row < src->h; ++row) {
 
  902                                 srcBuf = (Uint8*)(src->pixels) + (row * src->pitch);
 
  903                                 dstBuf = (Uint8*)(dst->pixels) + ((dst->h - row - 1) * dst->pitch) + (dst->w - 1) * bpp;
 
  904                                 for (col = 0; col < src->w; ++col) {
 
  905                                         memcpy (dstBuf, srcBuf, bpp);
 
  915                         for (row = 0; row < src->h; ++row) {
 
  916                                 srcBuf = (Uint8*)(src->pixels) + (row * src->pitch);
 
  917                                 dstBuf = (Uint8*)(dst->pixels) + (row * bpp) + (dst->h * dst->pitch);
 
  918                                 for (col = 0; col < src->w; ++col) {
 
  919                                         memcpy (dstBuf, srcBuf, bpp);
 
  921                                         dstBuf -= dst->pitch;
 
  929         if (SDL_MUSTLOCK(src)) {
 
  930                 SDL_UnlockSurface(src);
 
  932         if (SDL_MUSTLOCK(dst)) {
 
  933                 SDL_UnlockSurface(dst);
 
  955         int *dstwidth, 
int *dstheight, 
 
  956         double *canglezoom, 
double *sanglezoom)
 
  958         double x, y, cx, cy, sx, sy;
 
  960         int dstwidthhalf, dstheighthalf;
 
  965         radangle = angle * (
M_PI / 180.0);
 
  966         *sanglezoom = sin(radangle);
 
  967         *canglezoom = cos(radangle);
 
  968         *sanglezoom *= zoomx;
 
  969         *canglezoom *= zoomx;
 
  970         x = (double)(width / 2);
 
  971         y = (double)(height / 2);
 
  972         cx = *canglezoom * x;
 
  973         cy = *canglezoom * y;
 
  974         sx = *sanglezoom * x;
 
  975         sy = *sanglezoom * y;
 
  977         dstwidthhalf = 
MAX((
int)
 
  978                 ceil(
MAX(
MAX(
MAX(fabs(cx + sy), fabs(cx - sy)), fabs(-cx + sy)), fabs(-cx - sy))), 1);
 
  979         dstheighthalf = 
MAX((
int)
 
  980                 ceil(
MAX(
MAX(
MAX(fabs(sx + cy), fabs(sx - cy)), fabs(-sx + cy)), fabs(-sx - cy))), 1);
 
  981         *dstwidth = 2 * dstwidthhalf;
 
  982         *dstheight = 2 * dstheighthalf;
 
  996 void rotozoomSurfaceSizeXY(
int width, 
int height, 
double angle, 
double zoomx, 
double zoomy, 
int *dstwidth, 
int *dstheight)
 
  998         double dummy_sanglezoom, dummy_canglezoom;
 
 1000         _rotozoomSurfaceSizeTrig(width, height, angle, zoomx, zoomy, dstwidth, dstheight, &dummy_sanglezoom, &dummy_canglezoom);
 
 1015         double dummy_sanglezoom, dummy_canglezoom;
 
 1017         _rotozoomSurfaceSizeTrig(width, height, angle, zoom, zoom, dstwidth, dstheight, &dummy_sanglezoom, &dummy_canglezoom);
 
 1056 SDL_Surface *
rotozoomSurfaceXY(SDL_Surface * src, 
double angle, 
double zoomx, 
double zoomy, 
int smooth)
 
 1058         SDL_Surface *rz_src;
 
 1059         SDL_Surface *rz_dst;
 
 1061         double sanglezoom, canglezoom, sanglezoominv, canglezoominv;
 
 1062         int dstwidthhalf, dstwidth, dstheighthalf, dstheight;
 
 1064         int i, src_converted;
 
 1077         is32bit = (src->format->BitsPerPixel == 32);
 
 1078         if ((is32bit) || (src->format->BitsPerPixel == 8)) {
 
 1089                         SDL_CreateRGBSurface(SDL_SWSURFACE, src->w, src->h, 32, 
 
 1090 #
if SDL_BYTEORDER == SDL_LIL_ENDIAN
 
 1091                         0x000000ff, 0x0000ff00, 0x00ff0000, 0xff000000
 
 1093                         0xff000000,  0x00ff0000, 0x0000ff00, 0x000000ff
 
 1097                 SDL_BlitSurface(src, NULL, rz_src, NULL);
 
 1106         flipx = (zoomx<0.0);
 
 1107         if (flipx) zoomx=-zoomx;
 
 1108         flipy = (zoomy<0.0);
 
 1109         if (flipy) zoomy=-zoomy;
 
 1112         zoominv = 65536.0 / (zoomx * zoomx);
 
 1127                 _rotozoomSurfaceSizeTrig(rz_src->w, rz_src->h, angle, zoomx, zoomy, &dstwidth, &dstheight, &canglezoom, &sanglezoom);
 
 1132                 sanglezoominv = sanglezoom;
 
 1133                 canglezoominv = canglezoom;
 
 1134                 sanglezoominv *= zoominv;
 
 1135                 canglezoominv *= zoominv;
 
 1138                 dstwidthhalf = dstwidth / 2;
 
 1139                 dstheighthalf = dstheight / 2;
 
 1150                                 SDL_CreateRGBSurface(SDL_SWSURFACE, dstwidth, dstheight + 
GUARD_ROWS, 32,
 
 1151                                 rz_src->format->Rmask, rz_src->format->Gmask,
 
 1152                                 rz_src->format->Bmask, rz_src->format->Amask);
 
 1157                         rz_dst = SDL_CreateRGBSurface(SDL_SWSURFACE, dstwidth, dstheight + 
GUARD_ROWS, 8, 0, 0, 0, 0);
 
 1165                 rz_dst->h = dstheight;
 
 1170                 if (SDL_MUSTLOCK(rz_src)) {
 
 1171                         SDL_LockSurface(rz_src);
 
 1182                                 (
int) (sanglezoominv), (
int) (canglezoominv), 
 
 1189                         for (i = 0; i < rz_src->format->palette->ncolors; i++) {
 
 1190                                 rz_dst->format->palette->colors[i] = rz_src->format->palette->colors[i];
 
 1192                         rz_dst->format->palette->ncolors = rz_src->format->palette->ncolors;
 
 1197                                 (
int) (sanglezoominv), (
int) (canglezoominv),
 
 1203                 if (SDL_MUSTLOCK(rz_src)) {
 
 1204                         SDL_UnlockSurface(rz_src);
 
 1219                 zoomSurfaceSize(rz_src->w, rz_src->h, zoomx, zoomy, &dstwidth, &dstheight);
 
 1230                                 SDL_CreateRGBSurface(SDL_SWSURFACE, dstwidth, dstheight + 
GUARD_ROWS, 32,
 
 1231                                 rz_src->format->Rmask, rz_src->format->Gmask,
 
 1232                                 rz_src->format->Bmask, rz_src->format->Amask);
 
 1237                         rz_dst = SDL_CreateRGBSurface(SDL_SWSURFACE, dstwidth, dstheight + 
GUARD_ROWS, 8, 0, 0, 0, 0);
 
 1245                 rz_dst->h = dstheight;
 
 1250                 if (SDL_MUSTLOCK(rz_src)) {
 
 1251                         SDL_LockSurface(rz_src);
 
 1267                         for (i = 0; i < rz_src->format->palette->ncolors; i++) {
 
 1268                                 rz_dst->format->palette->colors[i] = rz_src->format->palette->colors[i];
 
 1270                         rz_dst->format->palette->ncolors = rz_src->format->palette->ncolors;
 
 1281                 if (SDL_MUSTLOCK(rz_src)) {
 
 1282                         SDL_UnlockSurface(rz_src);
 
 1289         if (src_converted) {
 
 1290                 SDL_FreeSurface(rz_src);
 
 1311 void zoomSurfaceSize(
int width, 
int height, 
double zoomx, 
double zoomy, 
int *dstwidth, 
int *dstheight)
 
 1317         flipx = (zoomx<0.0);
 
 1318         if (flipx) zoomx = -zoomx;
 
 1319         flipy = (zoomy<0.0);
 
 1320         if (flipy) zoomy = -zoomy;
 
 1335         *dstwidth = (int) floor(((
double) width * zoomx) + 0.5);
 
 1336         *dstheight = (int) floor(((
double) height * zoomy) + 0.5);
 
 1337         if (*dstwidth < 1) {
 
 1340         if (*dstheight < 1) {
 
 1361 SDL_Surface *
zoomSurface(SDL_Surface * src, 
double zoomx, 
double zoomy, 
int smooth)
 
 1363         SDL_Surface *rz_src;
 
 1364         SDL_Surface *rz_dst;
 
 1365         int dstwidth, dstheight;
 
 1367         int i, src_converted;
 
 1379         is32bit = (src->format->BitsPerPixel == 32);
 
 1380         if ((is32bit) || (src->format->BitsPerPixel == 8)) {
 
 1391                         SDL_CreateRGBSurface(SDL_SWSURFACE, src->w, src->h, 32, 
 
 1392 #
if SDL_BYTEORDER == SDL_LIL_ENDIAN
 
 1393                         0x000000ff, 0x0000ff00, 0x00ff0000, 0xff000000
 
 1395                         0xff000000,  0x00ff0000, 0x0000ff00, 0x000000ff
 
 1398                 if (rz_src == NULL) {
 
 1401                 SDL_BlitSurface(src, NULL, rz_src, NULL);
 
 1406         flipx = (zoomx<0.0);
 
 1407         if (flipx) zoomx = -zoomx;
 
 1408         flipy = (zoomy<0.0);
 
 1409         if (flipy) zoomy = -zoomy;
 
 1412         zoomSurfaceSize(rz_src->w, rz_src->h, zoomx, zoomy, &dstwidth, &dstheight);
 
 1423                         SDL_CreateRGBSurface(SDL_SWSURFACE, dstwidth, dstheight + 
GUARD_ROWS, 32,
 
 1424                         rz_src->format->Rmask, rz_src->format->Gmask,
 
 1425                         rz_src->format->Bmask, rz_src->format->Amask);
 
 1430                 rz_dst = SDL_CreateRGBSurface(SDL_SWSURFACE, dstwidth, dstheight + 
GUARD_ROWS, 8, 0, 0, 0, 0);
 
 1434         if (rz_dst == NULL) {
 
 1438                 if (src_converted) {
 
 1439                         SDL_FreeSurface(rz_src);
 
 1445         rz_dst->h = dstheight;
 
 1450         if (SDL_MUSTLOCK(rz_src)) {
 
 1451                 SDL_LockSurface(rz_src);
 
 1466                 for (i = 0; i < rz_src->format->palette->ncolors; i++) {
 
 1467                         rz_dst->format->palette->colors[i] = rz_src->format->palette->colors[i];
 
 1469                 rz_dst->format->palette->ncolors = rz_src->format->palette->ncolors;
 
 1478         if (SDL_MUSTLOCK(rz_src)) {
 
 1479                 SDL_UnlockSurface(rz_src);
 
 1485         if (src_converted) {
 
 1486                 SDL_FreeSurface(rz_src);
 
 1515         SDL_Surface *rz_src;
 
 1516         SDL_Surface *rz_dst = NULL;
 
 1517         int dstwidth, dstheight;
 
 1519         int i, src_converted;
 
 1532         is32bit = (src->format->BitsPerPixel == 32);
 
 1533         if ((is32bit) || (src->format->BitsPerPixel == 8)) {
 
 1543                 rz_src = SDL_CreateRGBSurface(SDL_SWSURFACE, src->w, src->h, 32, 
 
 1544 #
if SDL_BYTEORDER == SDL_LIL_ENDIAN
 
 1545                         0x000000ff, 0x0000ff00, 0x00ff0000, 0xff000000
 
 1547                         0xff000000,  0x00ff0000, 0x0000ff00, 0x000000ff
 
 1552                         goto exitShrinkSurface;
 
 1555                 SDL_BlitSurface(src, NULL, rz_src, NULL);
 
 1563         if (SDL_MUSTLOCK(rz_src)) {
 
 1564                 if (SDL_LockSurface(rz_src) < 0) {
 
 1566                         goto exitShrinkSurface;
 
 1571         dstwidth=rz_src->w/factorx;
 
 1572         while (dstwidth*factorx>rz_src->w) { dstwidth--; }
 
 1573         dstheight=rz_src->h/factory;
 
 1574         while (dstheight*factory>rz_src->h) { dstheight--; }
 
 1585                         SDL_CreateRGBSurface(SDL_SWSURFACE, dstwidth, dstheight + 
GUARD_ROWS, 32,
 
 1586                         rz_src->format->Rmask, rz_src->format->Gmask,
 
 1587                         rz_src->format->Bmask, rz_src->format->Amask);
 
 1592                 rz_dst = SDL_CreateRGBSurface(SDL_SWSURFACE, dstwidth, dstheight + 
GUARD_ROWS, 8, 0, 0, 0, 0);
 
 1596         if (rz_dst == NULL) {
 
 1598                 goto exitShrinkSurface;
 
 1602         rz_dst->h = dstheight;
 
 1612                 if ((result!=0) || (rz_dst==NULL)) {
 
 1614                         goto exitShrinkSurface;
 
 1620                 for (i = 0; i < rz_src->format->palette->ncolors; i++) {
 
 1621                         rz_dst->format->palette->colors[i] = rz_src->format->palette->colors[i];
 
 1623                 rz_dst->format->palette->ncolors = rz_src->format->palette->ncolors;
 
 1630                         goto exitShrinkSurface;
 
 1639                 if (SDL_MUSTLOCK(rz_src)) {
 
 1640                         SDL_UnlockSurface(rz_src);
 
 1646                 if (src_converted==1) {
 
 1647                         SDL_FreeSurface(rz_src);
 
 1654                         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-...
#define MAX(a, b)    
Returns maximum of two numbers a and b. 
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. 
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.