home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / unix / volume15 / touchup / part06 / magnify.c < prev    next >
Encoding:
C/C++ Source or Header  |  1988-06-14  |  1.7 KB  |  71 lines

  1. #include "header.h"
  2.  
  3. /*
  4.  *  Magnifying glass        (for Sun-3 workstations)
  5.  *
  6.  *  Copyright 1986, 1987 by Scott Schwartz
  7.  *  This program may be copied with the provision that this copyright 
  8.  *  message remains, and that further distribution of this code and it's 
  9.  *  derivatives is not subject to additional restrictions.
  10.  * 
  11.  *  Lots of changes, but no Copyright, by Mark Weiser.
  12.  * 
  13.  *  compile with -lsuntool -lsunwindow -lpixrect
  14.  *
  15.  */
  16.  
  17.  
  18. /* global vars */
  19. static struct pixrect    *tmpdst=NULL;
  20.  
  21.  
  22. quit_mag()
  23. {
  24.  MY_pr_destroy(tmpdst);
  25. }
  26.  
  27.  
  28. init_mag()
  29. {
  30.  MY_pr_destroy(tmpdst);
  31.  tmpdst = my_mem_create(SCREEN_MAX_X, SCREEN_MAX_Y, image_depth);
  32. }
  33.  
  34.  
  35. /*
  36.  * pw_mag copies a magnified view of spr to dpw using pixel replication.
  37.  * the arguments are the same as those to the pw_rop library call, except
  38.  * that magnification is passed instead of raster-op.
  39.  */
  40. void pw_mag(dpw, dx, dy, w, h, mag, spr, sx, sy)
  41.     Pixwin *dpw;    /* destination pixwin */
  42.     int dx, dy;      /* destination x,y */
  43.     int w, h;    /* width and height of block to copy */
  44.     int mag;     /* magnification */
  45.     struct pixrect *spr;    /* source pixrect */
  46.     int sx,sy;    /* location in source to copy from */
  47. {
  48.     /* locals */
  49.     register short jmax = h/mag + 1, imax = w/mag + 1;
  50.     register short x, y, delta;
  51.  
  52.     struct pixrect r;    /* holds the size of the drawing region when */
  53.             /* gaining access to the screen */
  54.     r.pr_size.x = w;
  55.     r.pr_size.y = h;
  56.  
  57.     for (x = 0; x < imax; x += 1) {
  58.         for (delta = 0; delta < mag; delta += 1) {
  59.             pr_rop(tmpdst, x*mag+delta, 0, 1, jmax, PIX_SRC|PIX_DONTCLIP, spr, sx+x, sy);
  60.         }
  61.     }
  62.     for (y = jmax; y >= 0; y -= 1) {
  63.         for (delta = 0; delta < mag; delta += 1) {
  64.             pr_rop(tmpdst, 0, y*mag+delta, w, 1, PIX_SRC|PIX_DONTCLIP, tmpdst, 0, y);
  65.         }
  66.     }
  67.  
  68.     /* draw */
  69.     pw_rop(dpw, dx, dy, w, h, PIX_SRC, tmpdst, 0, 0);
  70. }
  71.