-void Image_Resample24Lerp(const void *indata, int inwidth, int inheight, void *outdata, int outwidth, int outheight)
-{
- int i, j, r, yi, oldy, f, fstep, lerp, endy = (inheight-1), inwidth3 = inwidth * 3, outwidth3 = outwidth * 3;
- unsigned char *out;
- const unsigned char *inrow;
- unsigned char *resamplerow1;
- unsigned char *resamplerow2;
- out = (unsigned char *)outdata;
- fstep = (int) (inheight*65536.0f/outheight);
-
- resamplerow1 = (unsigned char *)Mem_Alloc(tempmempool, outwidth*3*2);
- resamplerow2 = resamplerow1 + outwidth*3;
-
- inrow = (const unsigned char *)indata;
- oldy = 0;
- Image_Resample24LerpLine (inrow, resamplerow1, inwidth, outwidth);
- Image_Resample24LerpLine (inrow + inwidth3, resamplerow2, inwidth, outwidth);
- for (i = 0, f = 0;i < outheight;i++,f += fstep)
- {
- yi = f >> 16;
- if (yi < endy)
- {
- lerp = f & 0xFFFF;
- if (yi != oldy)
- {
- inrow = (unsigned char *)indata + inwidth3*yi;
- if (yi == oldy+1)
- memcpy(resamplerow1, resamplerow2, outwidth3);
- else
- Image_Resample24LerpLine (inrow, resamplerow1, inwidth, outwidth);
- Image_Resample24LerpLine (inrow + inwidth3, resamplerow2, inwidth, outwidth);
- oldy = yi;
- }
- j = outwidth - 4;
- while(j >= 0)
- {
- LERPBYTE( 0);
- LERPBYTE( 1);
- LERPBYTE( 2);
- LERPBYTE( 3);
- LERPBYTE( 4);
- LERPBYTE( 5);
- LERPBYTE( 6);
- LERPBYTE( 7);
- LERPBYTE( 8);
- LERPBYTE( 9);
- LERPBYTE(10);
- LERPBYTE(11);
- out += 12;
- resamplerow1 += 12;
- resamplerow2 += 12;
- j -= 4;
- }
- if (j & 2)
- {
- LERPBYTE( 0);
- LERPBYTE( 1);
- LERPBYTE( 2);
- LERPBYTE( 3);
- LERPBYTE( 4);
- LERPBYTE( 5);
- out += 6;
- resamplerow1 += 6;
- resamplerow2 += 6;
- }
- if (j & 1)
- {
- LERPBYTE( 0);
- LERPBYTE( 1);
- LERPBYTE( 2);
- out += 3;
- resamplerow1 += 3;
- resamplerow2 += 3;
- }
- resamplerow1 -= outwidth3;
- resamplerow2 -= outwidth3;
- }
- else
- {
- if (yi != oldy)
- {
- inrow = (unsigned char *)indata + inwidth3*yi;
- if (yi == oldy+1)
- memcpy(resamplerow1, resamplerow2, outwidth3);
- else
- Image_Resample24LerpLine (inrow, resamplerow1, inwidth, outwidth);
- oldy = yi;
- }
- memcpy(out, resamplerow1, outwidth3);
- }
- }
- Mem_Free(resamplerow1);
- resamplerow1 = NULL;
- resamplerow2 = NULL;
-}
-
-void Image_Resample24Nolerp(const void *indata, int inwidth, int inheight, void *outdata, int outwidth, int outheight)
-{
- int i, j, f, inwidth3 = inwidth * 3;
- unsigned frac, fracstep;
- unsigned char *inrow, *out;
- out = (unsigned char *)outdata;
-
- fracstep = inwidth*0x10000/outwidth;
- for (i = 0;i < outheight;i++)
- {
- inrow = (unsigned char *)indata + inwidth3*(i*inheight/outheight);
- frac = fracstep >> 1;
- j = outwidth - 4;
- while (j >= 0)
- {
- f = (frac >> 16)*3;*out++ = inrow[f+0];*out++ = inrow[f+1];*out++ = inrow[f+2];frac += fracstep;
- f = (frac >> 16)*3;*out++ = inrow[f+0];*out++ = inrow[f+1];*out++ = inrow[f+2];frac += fracstep;
- f = (frac >> 16)*3;*out++ = inrow[f+0];*out++ = inrow[f+1];*out++ = inrow[f+2];frac += fracstep;
- f = (frac >> 16)*3;*out++ = inrow[f+0];*out++ = inrow[f+1];*out++ = inrow[f+2];frac += fracstep;
- j -= 4;
- }
- if (j & 2)
- {
- f = (frac >> 16)*3;*out++ = inrow[f+0];*out++ = inrow[f+1];*out++ = inrow[f+2];frac += fracstep;
- f = (frac >> 16)*3;*out++ = inrow[f+0];*out++ = inrow[f+1];*out++ = inrow[f+2];frac += fracstep;
- out += 2;
- }
- if (j & 1)
- {
- f = (frac >> 16)*3;*out++ = inrow[f+0];*out++ = inrow[f+1];*out++ = inrow[f+2];frac += fracstep;
- out += 1;
- }
- }
-}
-