|
DataMuseum.dkPresents historical artifacts from the history of: DKUUG/EUUG Conference tapes |
This is an automatic "excavation" of a thematic subset of
See our Wiki for more about DKUUG/EUUG Conference tapes Excavated with: AutoArchaeologist - Free & Open Source Software. |
top - downloadIndex: ┃ T s ┃
Length: 3606 (0xe16) Types: TextFile Names: »shzoom.c.old«
└─⟦a0efdde77⟧ Bits:30001252 EUUGD11 Tape, 1987 Spring Conference Helsinki └─ ⟦526ad3590⟧ »EUUGD11/gnu-31mar87/X.V10.R4.tar.Z« └─⟦2109abc41⟧ └─ ⟦this⟧ »./X.V10R4/showimg/shzoom.c.old«
#include <stdio.h> #include <X/Xlib.h> #define ZOOMFACT 4 /* zoom factor relative to parent window */ #define MIN(a,b) (((a) < (b)) ? (a) : (b)) #define MAX(a,b) (((a) > (b)) ? (a) : (b)) static unsigned char *zimage = NULL; /* pointer to storage */ static unsigned int zsize = 0; /* current storage size */ updatezoom(wzoom, xzoomsize, yzoomsize, x, y, xsize, ysize, image, wzfactor) Window wzoom; /* zoom window ID */ int xzoomsize, yzoomsize; /* zoom window size */ int x, y; /* center coord for zoom */ int xsize, ysize; /* size of original image */ unsigned char *image; /* 8-bit image */ int wzfactor; /* parent window zoom factor */ { unsigned char *malloc(), *free(); int i, f; register int j, xn, yn; register int rx = x, ry = y; if(rx<0 || rx>=xsize || ry<0 || ry>= ysize) return; /* recalculate the storage needed for nearest larger zoomed pixel */ f = ZOOMFACT * wzfactor; xn = xzoomsize/f + 1; yn = yzoomsize/f + 1; xzoomsize = xn*f; yzoomsize = yn*f; /* check available storage space */ if( (xzoomsize*yzoomsize) > zsize) { if(zimage != NULL) free(zimage); zsize = xzoomsize*yzoomsize; if((zimage = malloc(zsize)) == NULL) { fprintf(stderr,"Can't allocate zoom image buffer!\n"); exit(1); } /* fprintf(stderr,"aloocating zimage = %x, len =%d bytes\n",zimage,zsize); */ bzero(zimage,zsize); } /* fprintf(stderr,"Update zoom called: x= %d y= %d zoom= %d\n",rx, ry, f); fprintf(stderr," ncols= %d, nrows = %d\n", xsize,ysize); fflush(stderr); */ bzero(zimage,zsize); replicate(rx-xn/2,ry-yn/2,xsize,ysize,image,f, 0,0,xzoomsize,yzoomsize,zimage); /* if( (ry-yn/2) < 0) bzero(zimage,xzoomsize*(yn/2-ry)); if( (ry-yn/2+yn) > ysize) bzero(zimage+xzoomsize*(ysize-ry+yn/2), xzoomsize*(ry-yn/2+yn-ysize)); if( (rx-xn/2) < 0) for(j=0;j<yzoomsize;j++) bzero(zimage+j*xzoomsize,f*(xn/2-rx)); if( (rx-xn/2+xn) > xsize) for(j=0;j<yzoomsize;j++) bzero(zimage+j*xzoomsize+f*(xsize-rx+xn/2), f*(rx-xn/2+xn-xsize)); */ /* j is the location of the top left of the central pixel */ /* j = f*s*f*((s-1)/2) + f*((s-1)/2); i = j; zimage[i] = BlackPixel; i += f-1; zimage[i] = WhitePixel; i = j + f*s*(f-1); zimage[i] = WhitePixel; i += f-1; zimage[i] = BlackPixel; i = j - f*s - 1; zimage[i] = BlackPixel; i += f+1; zimage[i] = WhitePixel; i = j + f*s*(f-1) + f*s - 1; zimage[i] = WhitePixel; i += f+1; zimage[i] = BlackPixel; */ /* Let the Xwindow system take care of clipping */ XSync(); XPixmapBitsPutZ(wzoom,0,0,xzoomsize,yzoomsize,zimage,0,GXcopy,AllPlanes); } replicate(x0,y0,w0,h0,from,f,x,y,w,h,to) /* Fill array "to" with a piece of "from", each pixel mapping to fxf pixels */ unsigned char *from, *to; /* Source array, destination array */ int x0,y0,w0,h0; /* Source origin, dimensions */ int x,y,w,h; /* Destination origin, dimensions */ int f; /* Replication factor */ { register unsigned char *s, *d; register int k, n, i; int i0,i1,j0,j1,j; j0 = MAX(0,y0); j1 = MIN(h0,y0+(h-y)/f); i0 = MAX(0,x0); i1 = MIN(w0,x0+(w-x)/f); for(j=j0;j<j1;j++) { s = from + w0*j + i0; d = to + w*(f*(j-y0)+y) + x + f*(i0-x0); i = i1 - i0; n = f; while(i--) { k = n; while(k--) *d++ = *s; s++; } i = f-1; n = f*(i1-i0); s = d - f*(i1-i0); d = s + w; while(i--) { bcopy(s,d,n); d += w; } } }