rem: RSmoothScaleImage(RImage *src, int newWidth, int newHeight)
add: RSmoothScaleImage(RImage *src, unsigned new_width, unsigned new_height)
context: RSmoothScaleImage(RImage *src, int newWidth, int newHeight){        RImage *tmp;		       /* intermediate image */    double xscale, yscale;	       /* zoom scale factors */    int i, j, k;		       /* loop variables */    int n;			       /* pixel number */    double center, left, right;	       /* filter calculation variables */    double width, fscale;	       /* filter calculation variables */    double rweight, gweight, bweight;    RImage *dst;    unsigned char *rp, *gp, *bp;    unsigned char *rsp, *gsp, *bsp;    dst = RCreateImage(newWidth, newHeight, False);    /* create intermediate image to hold horizontal zoom */    tmp = RCreateImage(dst->width, src->height, False);    xscale = (double)newWidth / (double)src->width;    yscale = (double)newHeight / (double)src->height;    /* pre-calculate filter contributions for a row */    contrib = (CLIST *)calloc(newWidth, sizeof(CLIST));    if (xscale < 1.0) {	width = fwidth / xscale;	fscale = 1.0 / xscale;	for (i = 0; i < newWidth; ++i) {	    contrib[i].n = 0;	    contrib[i].p = (CONTRIB *)calloc((int)(width * 2 + 1),					     sizeof(CONTRIB));	    center = (double) i / xscale;	    left = ceil(center - width);	    right = floor(center + width);	    for(j = left; j <= right; ++j) {		rweight = center - (double) j;		rweight = (*filterf)(rweight / fscale) / fscale;		if(j < 0) {		    n = -j;		} else if(j >= src->width) {		    n = (src->width - j) + src->width - 1;		} else {		    n = j;		}		k = contrib[i].n++;		contrib[i].p[k].pixel = n;		contrib[i].p[k].weight = rweight;	    }	}    } else {	for(i = 0; i < newWidth; ++i) {	    contrib[i].n = 0;	    contrib[i].p = (CONTRIB *)calloc((int) (fwidth * 2 + 1),					     sizeof(CONTRIB));	    center = (double) i / xscale;	    left = ceil(center - fwidth);	    right = floor(center + fwidth);	    for(j = left; j <= right; ++j) {		rweight = center - (double) j;		rweight = (*filterf)(rweight);		if(j < 0) {		    n = -j;		} else if(j >= src->width) {		    n = (src->width - j) + src->width - 1;		} else {		    n = j;		}		k = contrib[i].n++;		contrib[i].p[k].pixel = n;		contrib[i].p[k].weight = rweight;	    }	}    }        /* apply filter to zoom horizontally from src to tmp */    rp = tmp->data[0];    gp = tmp->data[1];    bp = tmp->data[2];    for(k = 0; k < tmp->height; ++k) {	rsp = src->data[0] + src->width*k;	gsp = src->data[1] + src->width*k;	bsp = src->data[2] + src->width*k;	for(i = 0; i < tmp->width; ++i) {	    rweight = gweight = bweight = 0.0;	    for(j = 0; j < contrib[i].n; ++j) {		rweight += rsp[contrib[i].p[j].pixel] * contrib[i].p[j].weight;		gweight += gsp[contrib[i].p[j].pixel] * contrib[i].p[j].weight;		bweight += bsp[contrib[i].p[j].pixel] * contrib[i].p[j].weight;	    }	    *rp++ = CLAMP(rweight, 0, 255);	    *gp++ = CLAMP(gweight, 0, 255);	    *bp++ = CLAMP(bweight, 0, 255);	}    }    /* free the memory allocated for horizontal filter weights */    for(i = 0; i < tmp->width; ++i) {	free(contrib[i].p);    }    free(contrib);        /* pre-calculate filter contributions for a column */    contrib = (CLIST *)calloc(dst->height, sizeof(CLIST));    if(yscale < 1.0) {	width = fwidth / yscale;	fscale = 1.0 / yscale;	for(i = 0; i < dst->height; ++i) {	    contrib[i].n = 0;	    contrib[i].p = (CONTRIB *)calloc((int) (width * 2 + 1),					     sizeof(CONTRIB));	    center = (double) i / yscale;	    left = ceil(center - width);	    right = floor(center + width);	    for(j = left; j <= right; ++j) {		rweight = center - (double) j;		rweight = (*filterf)(rweight / fscale) / fscale;		if(j < 0) {		    n = -j;		} else if(j >= tmp->height) {		    n = (tmp->height - j) + tmp->height - 1;		} else {		    n = j;		}		k = contrib[i].n++;		contrib[i].p[k].pixel = n;		contrib[i].p[k].weight = rweight;	    }	}    } else {	for(i = 0; i < dst->height; ++i) {	    contrib[i].n = 0;	    contrib[i].p = (CONTRIB *)calloc((int) (fwidth * 2 + 1),					     sizeof(CONTRIB));	    center = (double) i / yscale;	    left = ceil(center - fwidth);	    right = floor(center + fwidth);	    for(j = left; j <= right; ++j) {		rweight = center - (double) j;		rweight = (*filterf)(rweight);		if(j < 0) {		    n = -j;		} else if(j >= tmp->height) {		    n = (tmp->height - j) + tmp->height - 1;		} else {		    n = j;		}		k = contrib[i].n++;		contrib[i].p[k].pixel = n;		contrib[i].p[k].weight = rweight;	    }	}    }    /* apply filter to zoom vertically from tmp to dst */    rsp = malloc(tmp->height);    gsp = malloc(tmp->height);    bsp = malloc(tmp->height);    for(k = 0; k < newWidth; ++k) {	rp = dst->data[0] + k;	gp = dst->data[1] + k;	bp = dst->data[2] + k;	/* copy a column into a row */	{	    int i;	    unsigned char *p, *d;	    d = rsp;	    for(i = tmp->height, p = tmp->data[0] + k; i-- > 0; 		p += tmp->width) {		*d++ = *p;	    }	    d = gsp;	    for(i = tmp->height, p = tmp->data[1] + k; i-- > 0; 		p += tmp->width) {		*d++ = *p;	    }	    d = bsp;	    for(i = tmp->height, p = tmp->data[2] + k; i-- > 0;		p += tmp->width) {		*d++ = *p;	    }	}	for(i = 0; i < newHeight; ++i) {	    rweight = gweight = bweight = 0.0;	    for(j = 0; j < contrib[i].n; ++j) {		rweight += rsp[contrib[i].p[j].pixel] * contrib[i].p[j].weight;		gweight += gsp[contrib[i].p[j].pixel] * contrib[i].p[j].weight;		bweight += bsp[contrib[i].p[j].pixel] * contrib[i].p[j].weight;	    }	    *rp = CLAMP(rweight, 0, 255);	    *gp = CLAMP(gweight, 0, 255);	    *bp = CLAMP(bweight, 0, 255);	    rp += newWidth;	    gp += newWidth;	    bp += newWidth;	}    }    free(rsp);    free(gsp);    free(bsp);        /* free the memory allocated for vertical filter weights */    for(i = 0; i < dst->height; ++i) {	free(contrib[i].p);    }    free(contrib);    RDestroyImage(tmp);    return dst;}