home *** CD-ROM | disk | FTP | other *** search
/ Graphics Plus / Graphics Plus.iso / general / plotting / imagetoo / imagetl1.lha / Imagetool / src+obj / zoom.c < prev   
Encoding:
C/C++ Source or Header  |  1991-03-11  |  14.8 KB  |  607 lines

  1. /* cat > headers/zoom.h << "EOF" */
  2. /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
  3. /* zoom.h: header for zoom.c file            */
  4. /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
  5. /* SCCS information: %W%    %G% - NCSA */
  6.  
  7. #define zoom_h        1
  8.  
  9. #include "all.h"
  10. #include "newext.h"
  11.  
  12.     static Panel_item xfac_item, yfac_item;
  13.  
  14.     static void fact_done ();
  15.     static Frame fact_box ();
  16.  
  17. /* EOF */
  18. /* cat > src+obj/zoom/comm_exp.c << "EOF" */
  19. /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
  20. /* comm_exp: routine to expand image            */
  21. /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
  22. /* SCCS information: %W%    %G% - NCSA */
  23.  
  24. /* #include "zoom.h" */
  25.  
  26. comm_exp (zmx, zmy)
  27.     int             zmx, zmy;
  28. {
  29.     char            filename[MAXNAMELEN];
  30.     unsigned char  *s, *t;
  31.     struct pixrect *pre_pr, *post_pr;
  32.     struct mpr_data *pre_mpr, *post_mpr;
  33.     int             fd, xdim, ydim, zx, zy, lastx, lasty;
  34.  
  35.     xdim = curr_image.xdim;
  36.     ydim = curr_image.ydim;
  37.     zx = xdim * zmx;
  38.     zy = ydim * zmy;
  39.     lastx = curr_image.startx;
  40.     lasty = curr_image.starty;
  41.  
  42.     if (strlen (curr_image.img_name) == 0)
  43.     {
  44.         msg_write ("Error: No image to zoom.");
  45.         return (-1);
  46.     }
  47.         /* check sizes */
  48.     if (!size_ok (zx, zy))
  49.     {
  50.         sprintf (wkstr, "Error: Cannot zoom to %d x %d. Limited to 1400 x 1000", zx, zy);
  51.         msg_write (wkstr);
  52.         return (-1);
  53.     }
  54.  
  55.         /* create memory */
  56.     if ((pre_pr = mem_create (xdim, ydim, 8)) == NULL)
  57.     {
  58.         msg_write ("Error: Not enough memory to create pixrect to zoom.");
  59.         return (-1);
  60.     }
  61.     if ((post_pr = mem_create (zx, zy, 8)) == NULL)
  62.     {
  63.         msg_write ("Error: Not enough memory to create pixrect for zoom.");
  64.         pr_close (pre_pr);
  65.         return (-1);
  66.     }
  67.     pre_mpr = mpr_d (pre_pr);
  68.     post_mpr = mpr_d (post_pr);
  69.     pw_read (pre_pr, 0, 0, xdim, ydim, PIX_SRC, pw, lastx, lasty);
  70.  
  71.         /* expand image */
  72.     s = (unsigned char *) pre_mpr->md_image;
  73.     t = (unsigned char *) post_mpr->md_image;
  74.     pix_expand (s, t, xdim, ydim, zmx, zmy);
  75.  
  76.         /* display the zoomed image */
  77.     erase_square ();
  78.     if (!pos_picked)
  79.     {
  80.         startx = lastx;
  81.         starty = lasty;
  82.     }
  83.  
  84.         /* put the expanded image to canvas */
  85.     pw_write (pw, startx, starty, zx, zy, PIX_SRC, post_pr, 0, 0);
  86.  
  87.     sprintf (wkstr, "Note: Image expanded to %d x %d.", zx, zy);
  88.     msg_write (wkstr);
  89.  
  90.         /* save info on last displayed image */
  91.     curr_image.xdim = zx;
  92.     curr_image.ydim = zy;
  93.     curr_image.startx = startx;
  94.     curr_image.starty = starty,
  95.     curr_image.zoomx = zmx;
  96.     curr_image.zoomy = zmy,
  97.     curr_image.expanded = 1;
  98.  
  99.     pos_picked = 0;
  100.     pr_close (pre_pr);
  101.     pr_close (post_pr);
  102.     return;
  103. }
  104. /* EOF */
  105. /* cat > src+obj/zoom/create_zoom_menu.c << "EOF" */
  106. /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
  107. /* create_soom_menu: create menu for zoom        */
  108. /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
  109. /* SCCS information: %W%    %G% - NCSA */
  110.  
  111. /* #include "zoom.h" */
  112.  
  113. create_zoom_menu ()
  114. {
  115.     zoom_menu = menu_create (
  116.                  MENU_FONT, font_menu,
  117.                  MENU_STRINGS,
  118.                     "Pixel (2X)",
  119.                     "Expand",
  120.                     "Interp (2X)",
  121.                     "Undo",
  122.                     0,
  123.                  MENU_NOTIFY_PROC, zoom_proc,
  124.                  0);
  125. }
  126. /* EOF */
  127. /* cat > src+obj/zoom/fact_box.c << "EOF" */
  128. /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
  129. /* fact_box: (static) create fact box            */
  130. /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
  131. /* SCCS information: %W%    %G% - NCSA */
  132.  
  133. /* #include "zoom.h" */
  134.  
  135. static          Frame
  136. fact_box ()
  137. {
  138.     static Frame    dialog;
  139.     static Panel    panel;
  140.     int             left, top, w, h;
  141.  
  142.     dialog = window_create (NULL, FRAME, FRAME_SHOW_LABEL, FALSE, 0);
  143.     panel = window_create (dialog, PANEL,
  144.                    WIN_FONT, font_panel,
  145.                    0);
  146.     panel_create_item (panel, PANEL_MESSAGE,
  147.                PANEL_LABEL_STRING, "Please enter expansion factors:",
  148.                PANEL_LABEL_BOLD, TRUE,
  149.                0);
  150.     xfac_item = panel_create_item (panel, PANEL_TEXT,
  151.                        PANEL_ITEM_X, 50,
  152.                        PANEL_ITEM_Y, 30,
  153.                        PANEL_VALUE_STORED_LENGTH, 10,
  154.                        PANEL_VALUE_DISPLAY_LENGTH, 10,
  155.                        PANEL_LABEL_STRING, "X factor: ",
  156.                        PANEL_LABEL_BOLD, TRUE,
  157.                        0);
  158.     yfac_item = panel_create_item (panel, PANEL_TEXT,
  159.                        /* PANEL_ITEM_X, 200, */
  160.                        PANEL_ITEM_Y, 30,
  161.                        PANEL_VALUE_STORED_LENGTH, 10,
  162.                        PANEL_VALUE_DISPLAY_LENGTH, 10,
  163.                        PANEL_LABEL_STRING, "Y factor: ",
  164.                        PANEL_LABEL_BOLD, TRUE,
  165.                        PANEL_NOTIFY_STRING, "\r\t\n",
  166.                        PANEL_NOTIFY_PROC, dialog_proc,
  167.                        0);
  168.     panel_create_item (panel, PANEL_BUTTON,
  169.                PANEL_ITEM_X, 300,
  170.                PANEL_ITEM_Y, 55,
  171.                PANEL_LABEL_IMAGE, panel_button_image (panel, "Ok", 3, font_panel_button),
  172.                PANEL_CLIENT_DATA, 1,
  173.                PANEL_NOTIFY_PROC, fact_done,
  174.                0);
  175.     panel_create_item (panel, PANEL_BUTTON,
  176.                /* PANEL_ITEM_X, 350, */
  177.                PANEL_ITEM_Y, 55,
  178.                PANEL_LABEL_IMAGE, panel_button_image (panel, "Cancel", 6, font_panel_button),
  179.                PANEL_CLIENT_DATA, 0,
  180.                PANEL_NOTIFY_PROC, fact_done,
  181.                0);
  182.     window_fit (panel);
  183.     window_fit (dialog);
  184.  
  185. /*
  186.     left = (int) window_get (base, WIN_X);
  187.     top = (int) window_get (base, WIN_Y);
  188.     w = (int) window_get (base, WIN_WIDTH);
  189.     h = (int) window_get (base, WIN_HEIGHT);
  190.     window_set (dialog, WIN_X, (left + w) / 4, WIN_Y, (top + h) / 4, 0);
  191. */
  192.         w = (int) window_get (dialog, WIN_WIDTH);
  193.     h = (int) window_get (dialog, WIN_HEIGHT);
  194.     window_set (dialog, WIN_X, 1150 / 2 - w / 2, WIN_Y, 900 / 2 - h / 2, 0);
  195.  
  196. /*
  197.     init_same_colormap((Pixwin *)window_get(dialog,WIN_PIXWIN));
  198.     init_same_colormap((Pixwin *)window_get(panel,WIN_PIXWIN));
  199. */
  200.     return dialog;
  201. }
  202. /* EOF */
  203. /* cat > src+obj/zoom/fact_done.c << "EOF" */
  204. /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
  205. /* fact_done: (static) fact done            */
  206. /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
  207. /* SCCS information: %W%    %G% - NCSA */
  208.  
  209. /* #include "zoom.h" */
  210.  
  211. static void
  212. fact_done (item, event)
  213.     Panel_item      item;
  214.     Event          *event;
  215. {
  216.     window_return ((int) panel_get (item, PANEL_CLIENT_DATA));
  217. }
  218. /* EOF */
  219. /* cat > src+obj/zoom/get_factors.c << "EOF" */
  220. /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
  221. /* get_factors: get expansion factors from user     */
  222. /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
  223. /* SCCS information: %W%    %G% - NCSA */
  224.  
  225. /* #include "zoom.h" */
  226.  
  227. get_factors (px, py)
  228.     int            *px, *py;
  229. {
  230.     static Frame    dialog_box;
  231.     char           *ptr;
  232.     char            str[11];
  233.     int             s_length, answer;
  234.  
  235.         /* display dialog box asking for user input */
  236.     dialog_box = fact_box ();
  237.     while ((answer = (int) window_loop (dialog_box)))
  238.     {
  239.         strcpy (str, (char *) panel_get_value (xfac_item));
  240.         *px = strtol (str, &ptr, 10);
  241.         if (*ptr != NULL || *px <= 0)
  242.         {
  243.             msg_write ("Error: Factor(s) must be positive integers. No f or e formats!");
  244.             continue;
  245.         }
  246.         strcpy (str, (char *) panel_get_value (yfac_item));
  247.         *py = strtol (str, &ptr, 10);
  248.         if (*ptr != NULL || *py <= 0)
  249.         {
  250.             msg_write ("Error: Factor(s) must be positive integers. No f or e formats!");
  251.             continue;
  252.         }
  253. /* printf */
  254. /* sprintf (wkstr, "get_factors: %d %d", *px, *py);
  255. msg_write (wkstr); */
  256.         break;
  257.     }
  258.  
  259.     window_set (dialog_box, FRAME_NO_CONFIRM, TRUE, 0);
  260.     window_destroy (dialog_box);
  261.     return (answer);
  262. }
  263. /* EOF */
  264. /* cat > src+obj/zoom/interp_image.c << "EOF" */
  265. /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
  266. /* interp_image: image interpolation 2x2 doing column    */
  267. /*         interpolation first then row        */
  268. /*         interpolation              */
  269. /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
  270. /* SCCS information: %W%    %G% - NCSA */
  271.  
  272. /* #include "zoom.h" */
  273.  
  274. interp_image (zmx, zmy)
  275.     int        zmx, zmy;
  276. {
  277.     struct pixrect *pre_pr, *col_pr, *row_pr;
  278.     struct mpr_data *pre_mpr, *col_mpr, *row_mpr;
  279.     int             col, row, xdim, ydim, zx, zy, lastx, lasty, i;
  280.     unsigned char  *s, *t;
  281.     unsigned int    v1, v2;
  282.     int        padt, pads;
  283.  
  284.     xdim = curr_image.xdim;
  285.     ydim = curr_image.ydim;
  286.     zx = zmx * xdim;
  287.     zy = zmy * ydim;
  288.     lastx = curr_image.startx;
  289.     lasty = curr_image.starty;
  290.  
  291.         if (strlen (curr_image.img_name) == 0)
  292.     {
  293.         msg_write ("Error: No image to zoom with interpolation.");
  294.         return (-1);
  295.     }
  296.  
  297.         /* check sizes */
  298.     if (!size_ok (zx, zy))
  299.     {
  300.         sprintf (wkstr, "Error: Cannot zoom to %d x %d. Limited to 1400 x 1000", zx, zy);
  301.         msg_write (wkstr);
  302.         return (-1);
  303.     }
  304.  
  305.         /* create memory */
  306.     if ((pre_pr = mem_create (xdim, ydim, 8)) == NULL)
  307.     {
  308.                 msg_write ("Error: Not enough memory to create pixrect to interpolate.");
  309.  
  310.         return (-1);
  311.     }
  312.     if ((col_pr = mem_create (zx, ydim, 8)) == NULL)
  313.     {
  314.                 msg_write ("Error: Not enough memory to create pixrect for column interpolant.");
  315.         pr_close (pre_pr);
  316.         return (-1);
  317.     }
  318.     pre_mpr = mpr_d (pre_pr);
  319.     col_mpr = mpr_d (col_pr);
  320.  
  321.         /* read in original image */
  322.     pw_read (pre_pr, 0, 0, xdim, ydim, PIX_SRC, pw, lastx, lasty);
  323.  
  324.     s = (unsigned char *) (pre_mpr->md_image);
  325.     t = (unsigned char *) (col_mpr->md_image);
  326.  
  327.         /* first pass doing column-wise for all rows */
  328.         pads = pixrect_pad (xdim);
  329.     padt = pixrect_pad (zx);
  330.     for (row = 0; row < ydim; row++)
  331.     {
  332.         for (col = 0; col < xdim - 1; col++)
  333.         {
  334.             v1 = *s;
  335.             v2 = *(s + 1);
  336.             *t = v1;
  337.             t++;
  338.             *t = (v1 + v2) / 2;
  339.             t++;
  340.             s++;
  341.         }
  342.             /* last pixel in row uses two identical values */
  343.         *t = *s;
  344.         t++;
  345.         *t = *s;
  346.         t++;
  347.         s++;
  348.         t += padt;
  349.         s += pads;
  350.     }
  351.     pr_close (pre_pr);
  352.  
  353.         /* create memory */
  354.     if ((row_pr = mem_create (zx, zy, 8)) == NULL)
  355.     {
  356.                 msg_write ("Error: Not enough memory to create pixrect for row and column interpolant.");
  357.         return;
  358.     }
  359.     row_mpr = mpr_d (row_pr);
  360.     s = (unsigned char *) (col_mpr->md_image);
  361.     t = (unsigned char *) (row_mpr->md_image);
  362.     for (col = 0; col < zx; col++)
  363.     {
  364.         s += col;
  365.         t += col;
  366.         for (row = 0; row < ydim - 1; row++)
  367.         {
  368.             v1 = *s;
  369.             v2 = *(s + zx + padt);
  370.             *t = v1;
  371.             *(t + zx + padt) = (v1 + v2) / 2;
  372.             s += zx;
  373.             t += 2 * (zx + padt);
  374.         }
  375.             /* last pixel in column */
  376.         *t = *s;
  377.         *(t + zx + padt) = *s;
  378.             /* reset to beginning */
  379.         s = (unsigned char *) col_mpr->md_image;
  380.         t = (unsigned char *) row_mpr->md_image;
  381.     }
  382.  
  383.         /* display the zoomed image */
  384.     erase_square ();
  385.     if (!pos_picked)
  386.     {
  387.         startx = lastx;
  388.         starty = lasty;
  389.     }
  390.     pw_write (pw, startx, starty, zx, zy, PIX_SRC, row_pr, 0, 0);
  391.     pr_close (col_pr);
  392.     pr_close (row_pr);
  393.  
  394.     sprintf (wkstr, "Note: Image zoomed with interpolation to %d x %d.", zx, zy);
  395.     msg_write (wkstr);
  396.  
  397.         /* save important info */
  398.     curr_image.xdim = zx;
  399.     curr_image.ydim = zy;
  400.     curr_image.startx = startx;
  401.     curr_image.starty = starty,
  402.     curr_image.zoomx = zmx;
  403.     curr_image.zoomy = zmy,
  404.     curr_image.expanded = 1;
  405.  
  406.     clear_request = 0;
  407.     first_middle_down = 0;
  408.     return (0);
  409. }
  410. /* EOF */
  411. /* cat > src+obj/zoom/pix_expand.c << "EOF" */
  412. /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
  413. /* pix_expand: routine to do pixel expansion         */
  414. /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
  415. /* SCCS information: %W%    %G% - NCSA */
  416.  
  417. /* #include "zoom.h" */
  418.  
  419. pix_expand (s, t, xdim, ydim, zoomx, zoomy)
  420.     char           *s, *t;
  421.     int             xdim, ydim, zoomx, zoomy;
  422. {
  423.     int             row, col, i, j;
  424.     char            ras_buf[MAXBUFSIZE];
  425.     int        pads, padt;
  426.  
  427.     pads = pixrect_pad (xdim);
  428.     padt = pixrect_pad (zoomx);
  429.     for (row = 0; row < ydim; row++)
  430.     {
  431.             /* expand row */
  432.         for (col = 0; col < xdim; col++)
  433.         {
  434.             for (i = 0; i < zoomx; i++)
  435.             {
  436.                 *t = ras_buf[col * zoomx + i] = *s;
  437.                 t++;
  438.             }
  439.             s++;
  440.         }
  441.         s += pads;
  442.         t += padt;
  443.             /* make copies of row */
  444.         for (i = 0; i < zoomy - 1; i++)
  445.         {
  446.             for (j = 0; j < xdim * zoomx; j++)
  447.             {
  448.                 *t = ras_buf[j];
  449.                 t++;
  450.             }
  451.             t += padt;
  452.         }
  453.     }
  454. }
  455. /* EOF */
  456. /* cat > src+obj/zoom/unexp_image.c << "EOF" */
  457. /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
  458. /* unexp_image: undo expansion                */
  459. /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
  460. /* SCCS information: %W%    %G% - NCSA */
  461.  
  462. /* #include "zoom.h" */
  463.  
  464. unexp_image ()
  465. {
  466.     char            ras_buf[MAXBUFSIZE], *s, *t;
  467.     struct pixrect *pre_pr, *post_pr;
  468.     struct mpr_data *pre_mpr, *post_mpr;
  469.     int             xdim, ydim, col, row;
  470.     int             lastw, lasth, lastx, lasty;
  471.     int             i, j;
  472.     int        pads, padt;
  473.  
  474.     lastw = curr_image.xdim;
  475.     lasth = curr_image.ydim;
  476.     lastx = curr_image.startx;
  477.     lasty = curr_image.starty;
  478.  
  479.         if (strlen (curr_image.img_name) == 0)
  480.     {
  481.         msg_write ("Error: No image to unzoom.");
  482.         return (-1);
  483.     }
  484.  
  485.     if (!curr_image.expanded)
  486.     {
  487.         msg_write ("Note: Current image not expanded.");
  488.         return (0);
  489.     }
  490.  
  491.         /* condition check */
  492.     if (lastw == curr_image.org_xdim && lasth == curr_image.org_ydim)
  493.     {
  494.         msg_write ("Note: Current image not expanded.");
  495.         curr_image.expanded = 0;
  496.         curr_image.zoomx = curr_image.zoomy = 1;
  497.         return (0);
  498.     }
  499.  
  500.     xdim = lastw / curr_image.zoomx;
  501.     ydim = lasth / curr_image.zoomy;
  502.  
  503.         /* create memory */
  504.     if ((pre_pr = mem_create (lastw, lasth, 8)) == NULL)
  505.     {
  506.                 msg_write ("Error: Not enough memory to create pixrect to unexpand.");
  507.          
  508.  
  509.         return (-1);
  510.     }
  511.     if ((post_pr = mem_create (xdim, ydim, 8)) == NULL)
  512.     {
  513.                 msg_write ("Error: Not enough memory to create pixrect for unexpand.");
  514.         pr_close (pre_pr);
  515.         return (-1);
  516.     }
  517.     pre_mpr = mpr_d (pre_pr);
  518.     post_mpr = mpr_d (post_pr);
  519.     pw_read (pre_pr, 0, 0, lastw, lasth, PIX_SRC, pw, lastx, lasty);
  520.  
  521.         /* unexpand an image */
  522.     s = (char *) pre_mpr->md_image;
  523.     t = (char *) post_mpr->md_image;
  524.     pads = pixrect_pad (lastw);
  525.     padt = pixrect_pad (xdim);
  526.     for (row = 0; row < ydim; row++)
  527.     {
  528.         for (col = 0; col < xdim; col++)
  529.         {
  530.             *t = *s;
  531.             s += curr_image.zoomx;
  532.             t++;
  533.         }
  534.         t += padt;
  535.         s += (curr_image.zoomy - 1) * (lastw + pads) + pads;
  536.     }
  537.  
  538.         /* display the unzoomed image */
  539.     erase_last ();
  540.     pw_write (pw, startx, starty, xdim, ydim, PIX_SRC, post_pr, 0, 0);
  541.     pr_close (pre_pr);
  542.     pr_close (post_pr);
  543.  
  544.         sprintf (wkstr, "Note: Image unzoomed to %d x %d.", xdim, ydim);
  545.     msg_write (wkstr);
  546.  
  547.     curr_image.xdim = xdim;
  548.     curr_image.ydim = ydim;
  549.  
  550.     clear_request = 0;
  551.     first_middle_down = 0;
  552.     return (0);
  553. }
  554. /* EOF */
  555. /* cat > src+obj/zoom/zoom_handler.c << "EOF" */
  556. /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
  557. /* zoom_handler: handler to display menu when zoom    */
  558. /*         is selected                 */
  559. /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
  560. /* SCCS information: %W%    %G% - NCSA */
  561.  
  562. /* #include "zoom.h" */
  563.  
  564. zoom_handler (item, event)
  565.     Panel_item      item;
  566.     Event          *event;
  567. {
  568.     if (display_panel_menu (item, event, menu_panel, zoom_menu))
  569.         zoom_proc (zoom_menu, menu_get (zoom_menu, MENU_NTH_ITEM, 1));
  570. }
  571. /* EOF */
  572. /* cat > src+obj/zoom/zoom_proc.c << "EOF" */
  573. /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
  574. /* zoom_proc: handler to process menu request        */
  575. /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
  576. /* SCCS information: %W%    %G% - NCSA */
  577.  
  578. /* #include "zoom.h" */
  579.  
  580. void
  581. zoom_proc (m, mi)
  582.     Menu            m;
  583.     Menu_item       mi;
  584. {
  585.     char            str[MAXNAMELEN];
  586.     int             zx, zy;
  587.  
  588.     strcpy (str, (char *) menu_get (mi, MENU_STRING));
  589.     if (!strcmp ("Pixel (2X)", str))
  590.         comm_exp (2, 2);
  591.     else if (!strcmp ("Expand", str))
  592.     {
  593.         if (get_factors (&zx, &zy))
  594.             comm_exp (zx, zy);
  595.     }
  596.     else if (!strcmp ("Interp (2X)", str))
  597.         interp_image (2, 2);
  598.     else
  599.         unexp_image ();
  600.  
  601.     clear_request = 0;
  602.     first_middle_down = 0;
  603.     square_drawn = 0;
  604.     return;
  605. }
  606. /* EOF */
  607.