-Image *zoom(Image *oimage, unsigned int xzoom, unsigned int yzoom)
-{
- Image *image;
- unsigned int *xindex, *yindex;
- unsigned int xwidth, ywidth;
- unsigned int x, y, xsrc, ysrc;
- unsigned int pixlen;
- unsigned int srclinelen;
- unsigned int destlinelen;
- byte *srcline, *srcptr;
- byte *destline, *destptr;
- byte srcmask, destmask, bit;
- Pixel value;
-
- if ((!xzoom || xzoom == 100) && (!yzoom || yzoom == 100))
- return(oimage);
-
- if (!xzoom)
- printf(" Zooming image Y axis by %d%%...", yzoom);
- else if (!yzoom)
- printf(" Zooming image X axis by %d%%...", xzoom);
- else if (xzoom == yzoom)
- printf(" Zooming image by %d%%...", xzoom);
- else
- printf(" Zooming image X axis by %d%% and Y axis by %d%%...",
- xzoom, yzoom);
- fflush(stdout);
-
- xindex = buildIndex(oimage->width, xzoom, &xwidth);
- yindex = buildIndex(oimage->height, yzoom, &ywidth);
-
- switch (oimage->type)
- {
- case IBITMAP:
- image = newBitImage(xwidth, ywidth);
- for (x=0; x<oimage->rgb.used; x++)
- {
- *(image->rgb.red + x) = *(oimage->rgb.red + x);
- *(image->rgb.green + x) = *(oimage->rgb.green + x);
- *(image->rgb.blue + x) = *(oimage->rgb.blue + x);
- }
- image->rgb.used = oimage->rgb.used;
- destline = image->data;
- destlinelen = (xwidth / 8) + (xwidth % 8 ? 1 : 0);
- srcline = oimage->data;
- srclinelen = (oimage->width / 8) + (oimage->width % 8 ? 1 : 0);
- for (y=0, ysrc=*(yindex + y); y<ywidth; y++)
- {
- while (ysrc != *(yindex + y))
- {
- ysrc++;
- srcline += srclinelen;
- }
- srcptr = srcline;
- destptr = destline;
- srcmask = 0x80;
- destmask = 0x80;
- bit = srcmask & *srcptr;
- for (x=0, xsrc=*(xindex + x); x<xwidth; x++)
- {
- if (xsrc != *(xindex + x))
- {
- do
- {
- xsrc++;
- if (!(srcmask >>= 1))
- {
- srcmask = 0x80;
- srcptr++;
- }
- }
- while (xsrc != *(xindex + x));
-
- bit = srcmask & *srcptr;
- }
- if (bit)
- *destptr |= destmask;
- if (!(destmask >>= 1))
- {
- destmask = 0x80;
- destptr++;
- }
- }
- destline += destlinelen;
- }
- break;