|
|
1.1 ! root 1: /* split off some utility functions */ ! 2: ! 3: #include <stdio.h> ! 4: #include <X/Xlib.h> ! 5: ! 6: #include "quad_arrow.cursor" ! 7: #include "quad_arrow_mask.cursor" ! 8: #include "pan.cursor" ! 9: #include "pan_mask.cursor" ! 10: #include "print.cursor" ! 11: #include "print_mask.cursor" ! 12: #include "zoom2.cursor" ! 13: #include "zoom2_mask.cursor" ! 14: #include "zoom4.cursor" ! 15: #include "zoom4_mask.cursor" ! 16: #include "pal.cursor" ! 17: #include "pal_mask.cursor" ! 18: ! 19: #define MIN(a,b) (((a) < (b)) ? (a) : (b)) ! 20: #define MAX(a,b) (((a) > (b)) ? (a) : (b)) ! 21: ! 22: #define SYNCINT 20 ! 23: ! 24: ipow( x, n) ! 25: register int x, n; ! 26: { ! 27: register int p; ! 28: for (p = 1; n > 0; --n) ! 29: p *= x; ! 30: return(p); ! 31: } ! 32: ! 33: make_cursors(imcursor,pancursor,printcursor,zoom2cursor,zoom4cursor, ! 34: palcursor) ! 35: Cursor *imcursor, *pancursor, *printcursor; ! 36: Cursor *zoom2cursor, *zoom4cursor, *palcursor; ! 37: { ! 38: Cursor XCreateCursor(); ! 39: ! 40: *imcursor = XCreateCursor(quad_arrow_width, quad_arrow_height, ! 41: quad_arrow_bits, ! 42: quad_arrow_mask_bits, ! 43: quad_arrow_x_hot, quad_arrow_y_hot, ! 44: BlackPixel, WhitePixel, GXcopy); ! 45: *pancursor = XCreateCursor(pan_width, pan_height, ! 46: pan_bits, ! 47: pan_mask_bits, ! 48: pan_x_hot, pan_y_hot, ! 49: BlackPixel, WhitePixel, GXcopy); ! 50: *printcursor = XCreateCursor(print_width, print_height, ! 51: print_bits, ! 52: print_mask_bits, ! 53: print_x_hot, print_y_hot, ! 54: BlackPixel, WhitePixel, GXcopy); ! 55: *zoom2cursor = XCreateCursor(zoom2_width, zoom2_height, ! 56: zoom2_bits, ! 57: zoom2_mask_bits, ! 58: zoom2_x_hot, zoom2_y_hot, ! 59: BlackPixel, WhitePixel, GXcopy); ! 60: *zoom4cursor = XCreateCursor(zoom4_width, zoom4_height, ! 61: zoom4_bits, ! 62: zoom4_mask_bits, ! 63: zoom4_x_hot, zoom4_y_hot, ! 64: BlackPixel, WhitePixel, GXcopy); ! 65: *palcursor = XCreateCursor(pal_width, pal_height, ! 66: pal_bits, ! 67: pal_mask_bits, ! 68: pal_x_hot, pal_y_hot, ! 69: BlackPixel, WhitePixel, GXcopy); ! 70: return; ! 71: } ! 72: ! 73: /* write image pixels to the screen according to location, ! 74: * zoom factor ! 75: */ ! 76: writepix(wind, image, ncols, nrows, zoomfactor, x, y, width, height, ! 77: xzero, yzero, mask,func,planes) ! 78: Window wind; ! 79: unsigned char *image; ! 80: short ncols, nrows, zoomfactor, x, y, width, height, xzero, yzero; ! 81: int mask, func, planes; ! 82: { ! 83: unsigned char linebuf[8192]; ! 84: int j, k, l, minw, ldebug = 0; ! 85: ! 86: register unsigned char *byteimage, *line = linebuf; ! 87: register int ncols_reg = ncols; ! 88: register minwidth, maxy; ! 89: register int i; ! 90: ! 91: minwidth = MIN((ncols_reg-x)<<zoomfactor, width); ! 92: maxy = MIN(nrows<<zoomfactor, y+height); ! 93: ! 94: byteimage = image + ((yzero + y) * ncols_reg) + xzero + x; ! 95: ! 96: XSync(0); ! 97: if(zoomfactor == 0) { ! 98: for(i=y; i<maxy; i++) { ! 99: XPixmapBitsPutZ(wind, x, i, ! 100: minwidth, 1, byteimage, mask, func, planes); ! 101: if((i % SYNCINT) == 0) XSync(0); ! 102: byteimage += ncols_reg; ! 103: } ! 104: return; ! 105: } else { ! 106: ! 107: l = 1<<zoomfactor; ! 108: ! 109: /* adjust for odd pixels */ ! 110: width += x & (l-1); ! 111: x -= x & (l-1); ! 112: height += y & (l-1); ! 113: y -= y & (l-1); ! 114: if(width & (l-1)) ! 115: width = (width & ~(l-1)) + l; ! 116: if(height & (l-1)) ! 117: height = (height & ~(l-1))+ l; ! 118: ! 119: minwidth = MIN((ncols_reg-(x>>zoomfactor))<<zoomfactor, width); ! 120: maxy = MIN(nrows<<zoomfactor, y+height); ! 121: minw = minwidth>>zoomfactor; ! 122: ! 123: byteimage = image + ((yzero + (y>>zoomfactor)) * ncols_reg) ! 124: + xzero + (x>>zoomfactor); ! 125: ! 126: for( j=y; j<maxy; j+=l) { ! 127: for(k=0; k<minw; k++ ) ! 128: for(i=0; i<l; i++) ! 129: *line++ = byteimage[k]; ! 130: line = linebuf; ! 131: for(i=0; i<l; i++) { ! 132: if(j+i >= maxy) return; ! 133: XPixmapBitsPutZ(wind, x, j+i, minwidth, 1, line, ! 134: mask, func, planes); ! 135: if(((i+j) % SYNCINT) == 0) XSync(0); ! 136: } ! 137: byteimage += ncols_reg; ! 138: } ! 139: } ! 140: return; ! 141: } ! 142: ! 143:
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.