home *** CD-ROM | disk | FTP | other *** search
/ Graphics Plus / Graphics Plus.iso / general / plotting / imagetoo / imagetl1.lha / Imagetool / src+obj / animation.c next >
Encoding:
C/C++ Source or Header  |  1991-03-11  |  19.7 KB  |  713 lines

  1. /* cat > headers/animation.h << "EOF" */
  2. /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
  3. /* animation.h: header for animation.c file        */
  4. /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
  5. /* SCCS information: %W%    %G% - NCSA */
  6.  
  7. #define    animation_h    1
  8.  
  9. #include "all.h"
  10. #include "newext.h"
  11.  
  12.     static Notify_value movie_frame();
  13.  
  14. /* EOF */
  15. /* cat > src+obj/animation/animate_proc.c << "EOF" */
  16. /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
  17. /* animate_proc: notify proc for animation menu        */
  18. /*         selection - works whether you use    */
  19. /*         the load_menu pull right or not!    */
  20. /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
  21. /* SCCS information: %W%    %G% - NCSA */
  22.  
  23. /* #include "image.h" */
  24.  
  25. animate_proc (m, mi)
  26.     Menu            m;
  27.     Menu_item       mi;
  28. {
  29.     invalid_stack ();
  30.     if (!strcmp ("Regular size", (char *) menu_get (mi, MENU_STRING)))
  31.         animation (0);
  32.     else
  33.         animation (1);
  34. }
  35. /* EOF */
  36. /* cat > src+obj/animation/animation.c << "EOF" */
  37. /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
  38. /* animation:  animation function accepts filename     */
  39. /*           with a wildcard. For example, 'dena*'    */
  40. /*           includes files starting with 'dena'.     */
  41. /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
  42. /* SCCS information: %W%    %G% - NCSA */
  43.  
  44. /* #include "image.h" */
  45.  
  46. animation (exp_factor)
  47. {
  48.     char            filename[MAXNAMELEN];
  49.     int             xdim, ydim, i;
  50.     int             status;
  51.     int             err;
  52.     enum desired_img_type in_type;
  53.     enum img_type   out_type;
  54.     int             index_type;
  55.     uint16          iref;
  56.     bool            load_pal, load_pal_old;
  57.  
  58.     if (animation_go)    /* don't overlay images */
  59.         return;
  60.  
  61.     clear_request = pause_request = 0;
  62.     square_drawn = line_drawn = 0;
  63.     first_middle_down = 0;
  64.  
  65.         /* get name */
  66.     fn = get_imagename ();    /* fn is a global! */
  67.     if (fn == NULL || fn[0] == NULL)
  68.         return;
  69.     else if (fn[1] == NULL)
  70.     {            /* only one image */
  71.             msg_write ("Warning: Only one image selected. No animation.");
  72.             load_single ((int) panel_get_value (load_toggle));
  73.             return;
  74.     }
  75.     else
  76.     {            /* a sequence of images */
  77.             nseq = 0;    /* nseq is a global! */
  78.             while (fn[nseq] != NULL)
  79.                 image[nseq++] = NULL;
  80.             if (nseq > MAXFRAMES)
  81.                 nseq = MAXFRAMES;
  82.     }
  83.  
  84.         /* get the dimensions from the first file fn[0] */
  85.     index_type = (int) panel_get_value (load_toggle);
  86.     in_type = index_type % 3;
  87.     load_pal = (index_type < 2) ? TRUE : FALSE;
  88.  
  89.     load_pal_old = load_pal;
  90.  
  91.     switch ((err = check_image (in_type, fn[0], &out_type, &xdim, &ydim, &iref, &load_pal)))
  92.     {
  93.         case 0:        /* no error */
  94.             break;
  95.         case 1:
  96.             msg_write ("Error: Image file does not exist for first image.");
  97.             msg_write ("Animation failed.");
  98.             return;
  99.         case 2:
  100.             msg_write ("Error: Dimension(s) are bad for first image.");
  101.             msg_write ("Animation failed.");
  102.             return;
  103.         case 3:
  104.             msg_write ("Error: Size of image doesn't match dimensions for first image.");
  105.             msg_write ("Animation failed.");
  106.             return;
  107.         case 4:
  108.             msg_write ("Error: No 8-bit Raster Image Set found in first image file.");
  109.             msg_write ("Animation failed.");
  110.             return;
  111.         case 5:
  112.             msg_write ("Error: No 2D Scientific Data Set found in first image file.");
  113.             msg_write ("Animation failed.");
  114.             return;
  115.         case 6:
  116.             msg_write ("Error: No 8-bit Raster Image Set or 2D Scientific Data Set found in first image file.");
  117.             msg_write ("Animation failed.");
  118.             return;
  119.         case 7:
  120.             sprintf (wkstr, "Error: Firts image too big!. (x, y) size = (%d, %d) not in range (%d, %d)", xdim, ydim, XMAX_IMAGE, YMAX_IMAGE);
  121.             msg_write (wkstr);
  122.             msg_write ("Animation failed.");
  123.             return;
  124.         default:
  125.             sprintf (wkstr, "HDF file error (DFerror = %d): While checking first image file.", err);
  126.             msg_write (wkstr);
  127.             msg_write ("Animation failed.");
  128.             return;
  129.     }
  130.  
  131.          /* allow loading frames */
  132.     curr_movie.startx = startx;
  133.     curr_movie.starty = starty;
  134.     curr_movie.org_xdim = xdim;
  135.     curr_movie.org_ydim = ydim;
  136.     curr_movie.nth_image = 0;
  137.     curr_movie.expanded = exp_factor;
  138.     if (exp_factor)
  139.     {
  140.         curr_movie.xdim = 2 * xdim;
  141.         curr_movie.ydim = 2 * ydim;
  142.         curr_movie.zoomx = curr_movie.zoomy = 2;
  143.     }
  144.     else
  145.     {
  146.         curr_movie.xdim = xdim;
  147.         curr_movie.ydim = ydim;
  148.         curr_movie.zoomx = curr_movie.zoomy = 1;
  149.     }
  150.  
  151.         /* start animation */
  152.     animation_go = 1;
  153.  
  154.         /* show buttons for fast operations */
  155.     valid_ani ();
  156.  
  157.         /* start timer for animation */
  158.     (void) notify_set_itimer_func (canvas, movie_frame,
  159.                        ITIMER_REAL, &NOTIFY_POLLING_ITIMER, NULL);
  160. }
  161. /* EOF */
  162. /* cat > src+obj/animation/create_animation_panel.c << "EOF" */
  163. /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
  164. /* create_animation_panel: create animation buttons    */
  165. /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
  166. /* SCCS information: %W%    %G% - NCSA */
  167.  
  168. /* #include "animation.h" */
  169.  
  170. int
  171. create_animation_panel ()
  172. {
  173.     int             x, y, ix;
  174.  
  175.     x = 50;
  176.     ix = 75;
  177.     y = 50;
  178.  
  179.  /* buttons for animation - visible only for animation */
  180.  
  181.     pause_but = panel_create_item (panel, PANEL_BUTTON,
  182.                        PANEL_ITEM_X, x,
  183.                        PANEL_ITEM_Y, y,
  184.                        PANEL_LABEL_IMAGE, panel_button_image (panel, "Pause", 6, font_panel_button),
  185.                        PANEL_MENU_CHOICE_STRINGS, "Pause animation", 0,
  186.                        PANEL_SHOW_MENU, TRUE,
  187.                        PANEL_SHOW_ITEM, FALSE,
  188.                        PANEL_NOTIFY_PROC, pause_seq,
  189.                        0);
  190.     last_but = panel_create_item (panel, PANEL_BUTTON,
  191.                       PANEL_ITEM_X, x + ix,
  192.                       PANEL_ITEM_Y, y,
  193.                       PANEL_LABEL_IMAGE, panel_button_image (panel, "Last", 6, font_panel_button),
  194.                       PANEL_MENU_CHOICE_STRINGS, "Last frame", 0,
  195.                       PANEL_SHOW_MENU, TRUE,
  196.                       PANEL_SHOW_ITEM, FALSE,
  197.                       PANEL_NOTIFY_PROC, last_seq,
  198.                       0);
  199.     next_but = panel_create_item (panel, PANEL_BUTTON,
  200.                       PANEL_ITEM_X, x + 2 * ix,
  201.                       PANEL_ITEM_Y, y,
  202.                       PANEL_LABEL_IMAGE, panel_button_image (panel, "Next", 6, font_panel_button),
  203.                       PANEL_MENU_CHOICE_STRINGS, "Next frame", 0,
  204.                       PANEL_SHOW_MENU, TRUE,
  205.                       PANEL_SHOW_ITEM, FALSE,
  206.                       PANEL_NOTIFY_PROC, next_seq,
  207.                       0);
  208.     inc_but = panel_create_item (panel, PANEL_BUTTON,
  209.                      PANEL_ITEM_X, x + 3 * ix,
  210.                      PANEL_ITEM_Y, y,
  211.                      PANEL_LABEL_IMAGE, panel_button_image (panel, "+", 1, font_panel_button),
  212.                      PANEL_MENU_CHOICE_STRINGS, "Increase speed", 0,
  213.                      PANEL_SHOW_MENU, TRUE,
  214.                      PANEL_SHOW_ITEM, FALSE,
  215.                      PANEL_NOTIFY_PROC, inc_speed,
  216.                      0);
  217.     dec_but = panel_create_item (panel, PANEL_BUTTON,
  218.                      PANEL_ITEM_X, x + 3 * ix + 40,
  219.                      PANEL_ITEM_Y, y,
  220.                      PANEL_LABEL_IMAGE, panel_button_image (panel, "-", 1, font_panel_button),
  221.                      PANEL_MENU_CHOICE_STRINGS, "Decrease speed", 0,
  222.                      PANEL_SHOW_MENU, TRUE,
  223.                      PANEL_SHOW_ITEM, FALSE,
  224.                      PANEL_NOTIFY_PROC, dec_speed,
  225.                      0);
  226. }
  227. /* EOF */
  228. /* cat > src+obj/animation/dec_speed.c << "EOF" */
  229. /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
  230. /* dec_speed: decrease speed                */
  231. /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
  232. /* SCCS information: %W%    %G% - NCSA */
  233.  
  234. /* #include "image.h" */
  235.  
  236. dec_speed (item, event)
  237.     Panel_item      item;
  238.     Event          *event;
  239. {
  240.     if (repeat_index < 20)
  241.         repeat_index++;
  242. }
  243. /* EOF */
  244. /* cat > src+obj/animation/done_seq.c << "EOF" */
  245. /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
  246. /* done_seq: clean up when animation ends         */
  247. /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
  248. /* SCCS information: %W%    %G% - NCSA */
  249.  
  250. /* #include "image.h" */
  251.  
  252. done_seq ()
  253. {
  254.     register        i;
  255.  
  256.     if (!animation_go)
  257.         return;
  258.  
  259.     (void) notify_set_itimer_func (canvas, movie_frame, ITIMER_REAL, NULL, NULL);
  260.     msg_write ("Note: Flushing images from memory . . .");
  261.     for (i = 0; i < nseq; i++)
  262.     {
  263.         if (image[i] != NULL)
  264.         {
  265. /* printf */
  266. /* sprintf (wkstr2, "done_seq: %d", i);
  267. msg_write (wkstr2); */
  268.             pr_close (image[i]);
  269.             image[i] = NULL;
  270.         }
  271.     }
  272.     (void) free_list (fn);
  273.  
  274.         /* clean the image area on the canvas */
  275.     pw_write (pw, curr_movie.startx, curr_movie.starty, curr_movie.xdim,
  276.           curr_movie.ydim, PIX_CLR, NULL, 0, 0);
  277.  
  278.     pause_request = 0;
  279.     animation_go = 0;
  280.     nseq = 0;
  281.     curr_movie.image = NULL;
  282.  
  283.     invalid_ani ();
  284. }
  285. /* EOF */
  286. /* cat > src+obj/animation/expand2.c << "EOF" */
  287. /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
  288. /* expand2: expand2                    */
  289. /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
  290. /* SCCS information: %W%    %G% - NCSA */
  291.  
  292. /* #include "image.h" */
  293.  
  294. struct pixrect *
  295. expand2 (pr1, xdim, ydim, zz)
  296.     struct pixrect *pr1;
  297.     int             xdim, ydim;
  298. {
  299.     struct pixrect *pr2;
  300.     struct mpr_data *mpr1, *mpr2;
  301.     char           *s, *t;
  302.  
  303.     if ((pr2 = mem_create (xdim * zz, ydim * zz, 8)) == NULL)
  304.     {
  305.         msg_write ("Error: Not enough memory to expand image.");
  306.         return (NULL);
  307.     }
  308.     mpr1 = mpr_d (pr1);
  309.     mpr2 = mpr_d (pr2);
  310.     s = (char *) mpr1->md_image;
  311.     t = (char *) mpr2->md_image;
  312.     pix_expand (s, t, xdim, ydim, zz, zz);
  313.     return (pr2);
  314. }
  315. /* EOF */
  316. /* cat > src+obj/animation/inc_speed.c << "EOF" */
  317. /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
  318. /* inc_speed: increase speed                */
  319. /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
  320. /* SCCS information: %W%    %G% - NCSA */
  321.  
  322. /* #include "image.h" */
  323.  
  324. inc_speed (item, event)
  325.     Panel_item      item;
  326.     Event          *event;
  327. {
  328.     if (repeat_index > 0)
  329.         repeat_index--;
  330. }
  331. /* EOF */
  332. /* cat > src+obj/animation/invalid_ani.c << "EOF" */
  333. /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
  334. /* invalid_ani: invalid animation            */
  335. /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
  336. /* SCCS information: %W%    %G% - NCSA */
  337.  
  338. /* #include "image.h" */
  339.  
  340. invalid_ani ()
  341. {
  342.     Menu_item       item;
  343.  
  344.         /* make all the animation buttons invisible */
  345.     if (panel_get (pause_but, PANEL_SHOW_ITEM, 0))
  346.     {
  347.         panel_set (pause_but, PANEL_SHOW_ITEM, FALSE, 0);
  348.         panel_set (last_but, PANEL_SHOW_ITEM, FALSE, 0);
  349.         panel_set (next_but, PANEL_SHOW_ITEM, FALSE, 0);
  350.         panel_set (inc_but, PANEL_SHOW_ITEM, FALSE, 0);
  351.         panel_set (dec_but, PANEL_SHOW_ITEM, FALSE, 0);
  352.     }
  353.  
  354.         /* disable stacking */
  355.     item = menu_get (image_menu, MENU_NTH_ITEM, 4, 0);
  356.     menu_set (item, MENU_INACTIVE, FALSE, 0);
  357. }
  358. /* EOF */
  359. /* cat > src+obj/animation/last_seq.c << "EOF" */
  360. /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
  361. /* last_seq: display previous frame in sequence when    */
  362. /*         pause                     */
  363. /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
  364. /* SCCS information: %W%    %G% - NCSA */
  365.  
  366. /* #include "image.h" */
  367.  
  368. last_seq (item, event)
  369.     Panel_item      item;
  370.     Event          *event;
  371. {
  372.     clear_request = 0;
  373.  
  374.     if (animation_go && pause_request)
  375.     {
  376.         if (--curr_movie.nth_image < 0)
  377.             curr_movie.nth_image = nseq - 1;
  378.         if (image[curr_movie.nth_image] == NULL)
  379.         {
  380.             if (++curr_movie.nth_image == nseq)
  381.                 curr_movie.nth_image = 0;
  382.             return;
  383.         }
  384.                 panel_set_value (image_board, fn[curr_movie.nth_image]);
  385.         pw_write (pw, curr_movie.startx, curr_movie.starty, curr_movie.xdim,
  386.               curr_movie.ydim, PIX_SRC, image[curr_movie.nth_image], 0, 0);
  387.     }
  388.     return;
  389.  
  390. }
  391. /* EOF */
  392. /* cat > src+obj/animation/load_movie_frame.c << "EOF" */
  393. /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
  394. /* load_movie_frame: load one frame into memory        */
  395. /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
  396. /* SCCS information: %W%    %G% - NCSA */
  397.  
  398. /* #include "image.h" */
  399.  
  400. load_movie_frame (i)
  401.     int             i;
  402. {
  403.     enum desired_img_type in_type;
  404.     enum img_type   out_type;
  405.     int             index_type, err;
  406.     int             dim_x, dim_y;
  407.     uint16          iref;
  408.     bool            load_pal, load_pal_old;
  409.  
  410.     dim_x = curr_movie.org_xdim;
  411.     dim_y = curr_movie.org_ydim;
  412.     startx = curr_movie.startx;
  413.     starty = curr_movie.starty;
  414.  
  415.     if (fn[i] != NULL && animation_go)
  416.     {
  417.         index_type = (int) panel_get_value (load_toggle);
  418.         in_type = index_type % 3;
  419.         load_pal = (index_type < 2) ? TRUE : FALSE;
  420.     
  421.         load_pal_old = load_pal;
  422.     
  423.             /* the global fn[i] contains the single filename */
  424.         switch ((err = check_image (in_type, fn[i], &out_type, &dim_x, &dim_y, &iref, &load_pal)))
  425.         {
  426.             case 0:        /* no error */
  427.                 break;
  428.             case 1:
  429.                 msg_write ("Error: Image file does not exist.");
  430. /* printf */
  431. /* sprintf (wkstr2, "load_movie_frame: %d, %s", i, fn[i]);
  432. msg_write (wkstr2); */
  433.                 return (-1);
  434.             case 2:
  435.                 msg_write ("Error: Dimension(s) are bad.");
  436.                 return (-1);
  437.             case 3:
  438.                 msg_write ("Error: Size of image doesn't match dimensions.");
  439.                 return (-1);
  440.             case 4:
  441.                 msg_write ("Error: No 8-bit Raster Image Set found in image file.");
  442.                 return (-1);
  443.             case 5:
  444.                 msg_write ("Error: No 2D Scientific Data Set found in image file.");
  445.                 return (-1);
  446.             case 6:
  447.                 msg_write ("Error: No 8-bit Raster Image Set or 2D Scientific Data Set found in image file.");
  448.                 return (-1);
  449.             case 7:
  450.                 sprintf (wkstr, "Error: Image too big!. (x, y) size = (%d, %d) not in range (%d, %d)", dim_x, dim_y, XMAX_IMAGE, YMAX_IMAGE);
  451.                 msg_write (wkstr);
  452.                 return (-1);
  453.             default:
  454.                 sprintf (wkstr, "HDF file error (DFerror = %d): While checking image file.", err);
  455.                 msg_write (wkstr);
  456.                 return (-1);
  457.         }
  458.         if (out_type == RIS8 && (load_pal != load_pal_old))
  459.             msg_write ("Warning: No palette with 8-bit Raster Image Set in image file.");
  460.         switch (out_type)
  461.         {
  462.             case RAWI:
  463.                 if (load_RAWI (fn[i], dim_x, dim_y, ANIMATION))
  464.                     return (-1);
  465.                 break;
  466.             case RIS8:
  467.                 if (load_RIS8 (fn[i], dim_x, dim_y, iref, load_pal, ANIMATION))
  468.                     return (-1);
  469.                 break;
  470.             case SDS2D:
  471.                 if (load_SDS2D (fn[i], dim_x, dim_y, ANIMATION))
  472.                     return (-1);
  473.             break;
  474.         }
  475.     }
  476. /* printf ("in_type = %d\n", in_type); */
  477.     return (0);
  478. }
  479. /* EOF */
  480. /* cat > src+obj/animation/load_single.c << "EOF" */
  481. /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
  482. /* load_single: load a single image from disk        */
  483. /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
  484. /* SCCS information: %W%    %G% - NCSA */
  485.  
  486. /* #include "image.h" */
  487.  
  488. int
  489. load_single (index_type)
  490.                 /* returns:    0 - success
  491.                            -1 - error     */
  492.     int             index_type;
  493.                 /* input: index of what to load from load_toggle */
  494. {
  495.     enum desired_img_type in_type;
  496.     enum img_type   out_type;
  497.     int             err;
  498.     int             dim_x, dim_y;
  499.     uint16          iref;
  500.     bool            load_pal, load_pal_old;
  501.  
  502.     in_type = index_type % 3;
  503.     load_pal = (index_type < 2) ? TRUE : FALSE;
  504.  
  505.     load_pal_old = load_pal;
  506.  
  507.         /* the global fn[0] contains the single filename */
  508.     switch ((err = check_image (in_type, fn[0], &out_type, &dim_x, &dim_y, &iref, &load_pal)))
  509.     {
  510.         case 0:        /* no error */
  511.             break;
  512.         case 1:
  513.             msg_write ("Error: Image file does not exist.");
  514.             return (-1);
  515.         case 2:
  516.             msg_write ("Error: Dimension(s) are bad.");
  517.             return (-1);
  518.         case 3:
  519.             msg_write ("Error: Size of image doesn't match dimensions.");
  520.             return (-1);
  521.         case 4:
  522.             msg_write ("Error: No 8-bit Raster Image Set found in image file.");
  523.             return (-1);
  524.         case 5:
  525.             msg_write ("Error: No 2D Scientific Data Set found in image file.");
  526.             return (-1);
  527.         case 6:
  528.             msg_write ("Error: No 8-bit Raster Image Set or 2D Scientific Data Set found in image file.");
  529.             return (-1);
  530.         case 7:
  531.             sprintf (wkstr, "Error: Image too big!. (x, y) size = (%d, %d) not in range (%d, %d)", dim_x, dim_y, XMAX_IMAGE, YMAX_IMAGE);
  532.             msg_write (wkstr);
  533.             return (-1);
  534.         default:
  535.             sprintf (wkstr, "HDF file error (DFerror = %d): While checking image file.", err);
  536.             msg_write (wkstr);
  537.             return (-1);
  538.     }
  539.     if (out_type == RIS8 && (load_pal != load_pal_old))
  540.         msg_write ("Warning: No palette with 8-bit Raster Image Set in image file.");
  541.     switch (out_type)
  542.     {
  543.         case RAWI:
  544.             if (load_RAWI (fn[0], dim_x, dim_y, SINGLE_IMAGE))
  545.                 return (-1);
  546.             break;
  547.         case RIS8:
  548.             if (load_RIS8 (fn[0], dim_x, dim_y, iref, load_pal, SINGLE_IMAGE))
  549.                 return (-1);
  550.             break;
  551.         case SDS2D:
  552.             if (load_SDS2D (fn[0], dim_x, dim_y, SINGLE_IMAGE))
  553.                 return (-1);
  554.         break;
  555.     }
  556. /* printf ("in_type = %d\n", in_type); */
  557.     return (0);
  558. }
  559. /* EOF */
  560. /* cat > src+obj/animation/movie_frame.c << "EOF" */
  561. /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
  562. /* movie_frame: (static) timer function called each    */
  563. /*        time when timer sends a signal        */
  564. /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
  565. /* SCCS information: %W%    %G% - NCSA */
  566.  
  567. /* #include "image.h" */
  568.  
  569. static          Notify_value
  570. movie_frame (client, itimer_type)
  571.     Notify_client   client;
  572.     int             itimer_type;
  573. {
  574.     int             i;
  575. /* printf */
  576. /* sprintf (wkstr, "movie_frame: %d %d", animation_go, curr_movie.nth_image);
  577. msg_write (wkstr); */
  578.     if (!animation_go)
  579.     {        /* interrupt */
  580.         done_seq ();
  581.         return (NOTIFY_DONE);
  582.     }
  583.  
  584.     if (image[curr_movie.nth_image] != NULL)
  585.     {        /* loaded, then playback */
  586.         panel_set_value (image_board, fn[curr_movie.nth_image]);        
  587.         for (i = 0; i <= repeat_index; i++)
  588.         {
  589.             pw_write (pw, curr_movie.startx, curr_movie.starty,
  590.                   curr_movie.xdim, curr_movie.ydim, PIX_SRC,
  591.                   image[curr_movie.nth_image], 0, 0);
  592.         }
  593.     }
  594.     else
  595.     {        /* load movie frame */
  596.         if (load_movie_frame (curr_movie.nth_image) == -1)
  597.         {        /* terminate */
  598.             nseq = curr_movie.nth_image;
  599.             curr_movie.nth_image = 0;
  600.             return (NOTIFY_DONE);
  601.         }
  602.         else
  603.             panel_set_value (image_board, fn[curr_movie.nth_image]);        
  604.     }
  605.  
  606.  /* advance a frame */
  607.     if (++curr_movie.nth_image >= nseq)
  608.         curr_movie.nth_image = 0;
  609.     return (NOTIFY_DONE);
  610. }
  611. /* EOF */
  612. /* cat > src+obj/animation/next_seq.c << "EOF" */
  613. /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
  614. /* next_seq: display next frame in sequence when pause     */
  615. /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
  616. /* SCCS information: %W%    %G% - NCSA */
  617.  
  618. /* #include "image.h" */
  619.  
  620. next_seq (item, event)
  621.     Panel_item      item;
  622.     Event          *event;
  623. {
  624.     clear_request = 0;
  625.  
  626.     if (animation_go && pause_request)
  627.     {
  628.         if (++curr_movie.nth_image >= nseq)
  629.             curr_movie.nth_image = 0;
  630.         if (image[curr_movie.nth_image] == NULL)
  631.         {
  632.             if (--curr_movie.nth_image < 0)
  633.                 curr_movie.nth_image = nseq - 1;
  634.             return;
  635.         }
  636.                 panel_set_value (image_board, fn[curr_movie.nth_image]);
  637.         pw_write (pw, curr_movie.startx, curr_movie.starty, curr_movie.xdim,
  638.               curr_movie.ydim, PIX_SRC, image[curr_movie.nth_image], 0, 0);
  639.     }
  640.     return;
  641. }
  642. /* EOF */
  643. /* cat > src+obj/animation/pause_seq.c << "EOF" */
  644. /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
  645. /* pause_seq: pause animation                */
  646. /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
  647. /* SCCS information: %W%    %G% - NCSA */
  648.  
  649. /* #include "image.h" */
  650.  
  651. pause_seq (item, event)
  652.     Panel_item      item;
  653.     Event          *event;
  654. {
  655.     register        i;
  656.  
  657. /* printf */
  658. /* sprintf (wkstr, "pause_seq: %d %d", animation_go, pause_request);
  659. msg_write (wkstr); */
  660.     if (animation_go)
  661.     {
  662.         if (!pause_request)
  663.         {
  664.             (void) notify_set_itimer_func (canvas, movie_frame,
  665.                                ITIMER_REAL, NULL, NULL);
  666.             pause_request = 1;
  667.             if (--curr_movie.nth_image < 0)
  668.                 curr_movie.nth_image = nseq - 1;
  669.  
  670.             curr_image.startx = curr_movie.startx;
  671.             curr_image.starty = curr_movie.starty;
  672.             curr_image.org_xdim = curr_movie.org_xdim;
  673.             curr_image.org_ydim = curr_movie.org_ydim;
  674.             curr_image.xdim = curr_movie.xdim;
  675.             curr_image.ydim = curr_movie.ydim;
  676.             curr_image.zoomx = curr_movie.zoomx;
  677.             curr_image.zoomy = curr_movie.zoomy;
  678.             curr_image.expanded = curr_movie.expanded;
  679.             curr_image.nth_image = curr_movie.nth_image;
  680.             curr_image.image = NULL;
  681.         }
  682.         else
  683.         {
  684.             (void) notify_set_itimer_func (canvas, movie_frame,
  685.                                ITIMER_REAL, &NOTIFY_POLLING_ITIMER, NULL);
  686.             pause_request = 0;
  687.         }
  688.     }
  689.     return;
  690. }
  691. /* EOF */
  692. /* cat > src+obj/animation/valid_ani.c << "EOF" */
  693. /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
  694. /* valid_ani: valid animation                */
  695. /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
  696. /* SCCS information: %W%    %G% - NCSA */
  697.  
  698. /* #include "image.h" */
  699.  
  700. valid_ani ()
  701. {
  702.     Menu_item       item;
  703.  
  704.     panel_set (pause_but, PANEL_SHOW_ITEM, TRUE, 0);
  705.     panel_set (next_but, PANEL_SHOW_ITEM, TRUE, 0);
  706.     panel_set (last_but, PANEL_SHOW_ITEM, TRUE, 0);
  707.     panel_set (inc_but, PANEL_SHOW_ITEM, TRUE, 0);
  708.     panel_set (dec_but, PANEL_SHOW_ITEM, TRUE, 0);
  709.     item = menu_get (image_menu, MENU_NTH_ITEM, 4, 0);
  710.     menu_set (item, MENU_INACTIVE, TRUE, 0);
  711. }
  712. /* EOF */
  713.