Hi!
Brian pointed me to the matrox mystique doc, which describes its
stretching algorithm. Xavier Hienne sent me his code, he wrote some
time and Andy gave me a good comment (accidently to the list :).
I picked the best out of each (including my own ideas) and here is
the result:
=========================================================================0
int stretch(ggiBlt_t bob, int dx, int dy, int width, int height)
{
int i;
int y,ystart;
int bob_ystart;
double bob_idx, bob_y;
double bob_xinc, bob_yinc;
ggi_color color;
y = 0;
ystart = y * width;
bob_y = 0.0f;
bob_ystart = (int)(bob_y) * bob->w;
bob_idx = 0.0f;
bob_xinc = (double)(width / bob->w);
bob_yinc = (double)(height / bob->h);
for (i = ystart; i < (width * height);) {
GetPixel((int)(bob_idx) - bob_ystart, (int)bob_y, &color);
PutPixel(dx + i - ystart, dy + y, color);
i++;
bob_idx += bob_xinc;
if ((i - ystart) == width) {
/* newline */
ystart = i;
y++;
} /* if */
if (((int)(bob_idx) - bob_ystart) >= bob->w) {
/* newline */
bob_ystart = (int)bob_idx;
bob_y += bob_yinc;
} /* if */
} /* for */
} /* stretch */
=========================================================================0
Comments?
CU,
Christoph Egger
E-Mail: [EMAIL PROTECTED]