home *** CD-ROM | disk | FTP | other *** search
/ Graphics Plus / Graphics Plus.iso / general / procssng / ccs / ccs-11tl.lha / lbl / xview / segal / zoom.c < prev   
Encoding:
C/C++ Source or Header  |  1992-09-23  |  1.3 KB  |  47 lines

  1. /*    zoom.c - for use with segal
  2.  *
  3.  *    zooms an area of an image
  4.  */
  5.  
  6. #include "common.h"
  7.  
  8. /************************************************************/
  9. void
  10. zoom_to_ximage(win_id)
  11. int win_id;
  12. {
  13. /* Replicates data in the upper left corner of the ximage to fill the entire
  14.  * ximage.
  15.  */
  16.     int i;
  17.     int x1, y1;
  18.     int sx, sy, y0;
  19.  
  20.     if(win[win_id].zoom_mag <= 1) {
  21.         bcopy(win[win_id].z_data[0],
  22.             (u_char *) win[win_id].ximg->data,
  23.             win[win_id].img_size);
  24.         return;
  25.     }
  26.  
  27.     /* Magnify in the X direction */
  28.     /* start in the upper right corner of the data and expand */
  29.     for(x1 = win[win_id].img_c - 1; x1 >= 0; x1--)
  30.     for(y1 = 0; y1 < win[win_id].img_r; y1++) {
  31.         sx = x1 * win[win_id].zoom_mag;
  32.         sy = y1 * win[win_id].ximg->bytes_per_line;
  33.         for(i = sx; i < sx + win[win_id].zoom_mag; i++)
  34.             win[win_id].ximg->data[i + sy] = win[win_id].z_data[y1][x1];
  35.     }
  36.  
  37.     /* Magnify in the Y direction */
  38.     /* start with the lower left corner of the data and expand */
  39.     for(x1 = 0; x1 < win[win_id].ximg->width; x1++)
  40.     for(y1 = win[win_id].img_r - 1; y1 > 0; y1--) {
  41.         y0 = y1 * win[win_id].ximg->bytes_per_line;
  42.         sy = y1 * win[win_id].zoom_mag;
  43.         for(i = sy; i < sy + win[win_id].zoom_mag; i++)
  44.             win[win_id].ximg->data[x1 + i * win[win_id].ximg->bytes_per_line] = win[win_id].ximg->data[x1 + y0];
  45.     }
  46. }
  47.