more cleanups, and un-break it

This commit is contained in:
Glenn Maynard
2002-10-29 01:55:38 +00:00
parent d0f715c7e8
commit acfc6d33fd
+12 -23
View File
@@ -16,16 +16,9 @@
#include <stdlib.h> #include <stdlib.h>
#include <math.h> #include <math.h>
typedef struct tColorRGBA { struct tColorRGBA {
Uint8 r; Uint8 r,g,b,a;
Uint8 g; };
Uint8 b;
Uint8 a;
} tColorRGBA;
typedef struct tColorY {
Uint8 y;
} tColorY;
#define MAX(a,b) (((a) > (b)) ? (a) : (b)) #define MAX(a,b) (((a) > (b)) ? (a) : (b))
@@ -49,8 +42,8 @@ int zoomSurfaceRGBA(SDL_Surface * src, SDL_Surface * dst, int smooth)
// sx = (int) (65536.0 * (float) (src->w - 1) / (float) dst->w); // sx = (int) (65536.0 * (float) (src->w - 1) / (float) dst->w);
// sy = (int) (65536.0 * (float) (src->h - 1) / (float) dst->h); // sy = (int) (65536.0 * (float) (src->h - 1) / (float) dst->h);
// } else { // } else {
sx = (int) (65536.0 * (float) src->w / (float) dst->w); sx = 65536 * src->w / dst->w;
sy = (int) (65536.0 * (float) src->h / (float) dst->h); sy = 65536 * src->h / dst->h;
//} //}
/* Allocate memory for row increments */ /* Allocate memory for row increments */
@@ -66,27 +59,23 @@ int zoomSurfaceRGBA(SDL_Surface * src, SDL_Surface * dst, int smooth)
int csx = 0; int csx = 0;
int *csax = sax; int *csax = sax;
for (x = 0; x <= dst->w; x++) { for (x = 0; x <= dst->w; x++) {
csx &= 0xffff;
*csax = csx; *csax = csx;
csx &= 0xffff;
csax++; csax++;
csx += sx; csx += sx;
} }
int csy = 0; int csy = 0;
int *csay = say; int *csay = say;
for (y = 0; y <= dst->h; y++) { for (y = 0; y <= dst->h; y++) {
csy &= 0xffff;
*csay = csy; *csay = csy;
csy &= 0xffff;
csay++; csay++;
csy += sy; csy += sy;
} }
/* /* Pointer setup */
* Pointer setup
*/
tColorRGBA *sp, *csp; tColorRGBA *sp, *csp;
sp = csp = (tColorRGBA *) src->pixels; sp = csp = (tColorRGBA *) src->pixels;
int sgap = src->pitch - src->w * 4;
int dgap = dst->pitch - dst->w * 4;
/* Switch between interpolating and non-interpolating code */ /* Switch between interpolating and non-interpolating code */
csay = say; csay = say;
@@ -102,15 +91,15 @@ int zoomSurfaceRGBA(SDL_Surface * src, SDL_Surface * dst, int smooth)
tColorRGBA *c11 = c10+1; tColorRGBA *c11 = c10+1;
csax = sax; csax = sax;
/* Set destination pointer. */ /* Set destination pointer. */
tColorRGBA *dp = (tColorRGBA *) ((Uint8 *) dst->pixels + dgap*y); tColorRGBA *dp = (tColorRGBA *) ((Uint8 *) dst->pixels + dst->pitch*y);
for (x = 0; x < dst->w; x++) { for (x = 0; x < dst->w; x++) {
/* /*
* Interpolate colors * Interpolate colors
*/ */
int ex = *csax; int ex = *csax & 0xffff;
int ey = *csay; int ey = *csay & 0xffff;
int t1, t2; int t1, t2;
t1 = ((((c01->r - c00->r) * ex) >> 16) + c00->r) & 0xff; t1 = ((((c01->r - c00->r) * ex) >> 16) + c00->r) & 0xff;
t2 = ((((c11->r - c10->r) * ex) >> 16) + c10->r) & 0xff; t2 = ((((c11->r - c10->r) * ex) >> 16) + c10->r) & 0xff;
@@ -145,7 +134,7 @@ int zoomSurfaceRGBA(SDL_Surface * src, SDL_Surface * dst, int smooth)
for (y = 0; y < dst->h; y++) { for (y = 0; y < dst->h; y++) {
sp = csp; sp = csp;
csax = sax; csax = sax;
tColorRGBA *dp = (tColorRGBA *) ((Uint8 *) dst->pixels + dgap*y); tColorRGBA *dp = (tColorRGBA *) ((Uint8 *) dst->pixels + dst->pitch*y);
for (x = 0; x < dst->w; x++) { for (x = 0; x < dst->w; x++) {
/* Draw */ /* Draw */
*dp = *sp; *dp = *sp;