home *** CD-ROM | disk | FTP | other *** search
/ Graphics Plus / Graphics Plus.iso / general / procssng / ccs / ccs-11tl.lha / lbl / x11 / lib / ld_image.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-08-16  |  3.0 KB  |  112 lines

  1. /*    LoaD_IMAGE . C
  2. #
  3. %    Copyright (c)    see included header files
  4. %
  5. % AUTHOR:    Jin Guojun - LBL    10/1/91
  6. */
  7.  
  8. #include "function.h"
  9.  
  10. extern    int    rw_set;
  11.  
  12. image_information*
  13. dup_mv_hd(img, previous)
  14. image_information*    img, *previous;
  15. {
  16. #define    cpl1    sizeof(int) * 18
  17. #define    cpl2    sizeof(int) * 11
  18. #define INHERIT(thing)    img->thing = previous->thing
  19.         memcpy(&img->colormap, &previous->colormap, cpl1);
  20.         memcpy(&img->dpy_depth, &previous->dpy_depth, cpl1);
  21.         memcpy(&img->in_type, &previous->in_type, cpl2);
  22.         memcpy(&img->map_scanline, &previous->map_scanline, cpl2);
  23.         if (stingy_flag)    img->image = NULL;
  24.         INHERIT(icn_pixmap);
  25.         INHERIT(divN);
  26.         INHERIT(modN);
  27.         INHERIT(dm16);
  28.         INHERIT(pixel_table);
  29.         INHERIT(lvls);
  30.         INHERIT(lvls_squared);
  31.         INHERIT(visual_class);
  32. #undef INHERIT
  33. return    previous;
  34. }
  35.  
  36. LoadGXImage(num_images, parent, pic, movie, win_geom, still_win)
  37. int    *num_images;
  38. Image    *parent, ***pic;
  39. char    *win_geom;
  40. {
  41. int    loaded=0, rle_cnt=0, status, vbs=0;
  42.     Loop {
  43.     Image    *img, *previous_img=NULL;
  44.  
  45.     vbs += verify_buffer_size(pic, -sizeof(**pic), *num_images+1, No);
  46.     if (!*pic)    prgmerr(RLE_NO_SPACE, "out of memory!");
  47.     if (vbs)    (*pic)[*num_images] = NULL;
  48.     if (still_win)    for (status=*num_images; status--;)
  49.         if (!strcmp((*pic)[status]->name, parent->name))    break;
  50.     if ((!still_win || status < 1) && !(*pic)[*num_images])    {
  51.         img = (*pic)[*num_images] = (Image*)ZALLOC(1, sizeof(*img), "img");
  52.  
  53.         img->visual_class = parent->visual_class;
  54.         init_img_info(img, Dpy, RLE, parent->dpy);
  55.  
  56.         /*    we need pixmaps for movie mode    */
  57.         img->pixmap_failed = parent->pixmap_failed;
  58.         img->gamma = parent->gamma;
  59.         img->name = parent->name;
  60.         img->IN_FP = parent->IN_FP;
  61.     } else    img = (*pic)[status],    --*num_images,    previous_img = img;
  62.     if (movie && *num_images)
  63.         previous_img = dup_mv_hd(img, (*pic)[*num_images-1]);
  64.     else    init_img_flag(img),    multi_hd = 0;
  65.  
  66.     if (rle_cnt)    /* may be a sequence image */
  67.         multi_hd++;
  68.     img->frames = rle_cnt;
  69.  
  70.     status = get_pic(*num_images, win_geom, previous_img, *pic, 1);
  71.  
  72.     {
  73.     register int    mult_f = img->frames>1, i_t = img->in_type;
  74.  
  75.     switch (status) {
  76.     case SUCCESS:
  77.         loaded = rw_set = ++*num_images;
  78.         if (i_t!=HIPS && i_t!=FITS && i_t!=JPEG || movie)    {
  79.             rle_cnt++;
  80.             continue;
  81.         }
  82.         if (mult_f)    {
  83.             verify_buffer_size(&img->data, -img->dpy_channels,
  84.                 img->width*img->height << 1, "realloc MultiF");
  85.             (*img->std_swif)(FI_RLOAD_BUF, img, img->data +
  86.                 img->width*img->height*img->dpy_channels, OsameI);
  87.             if (!tuner_flag)
  88.                 img->scan_data = img->data;
  89.         }
  90.         img->fn++;
  91.  
  92.     case RLE_EMPTY:
  93.     case RLE_EOF:
  94.     case EOF:    /* = RLE_NOT_RLE    */
  95.         if ((status==RLE_NOT_RLE || !rle_cnt) && (DEBUGANY | verbose))
  96.             rle_get_error(status, Progname, img->name);
  97. EOF_case:    if (!mult_f)    fclose(img->IN_FP);
  98.         if (rle_cnt)
  99.             free (img /* == pic[*num_images] */),
  100.             (*pic)[*num_images] = NULL;
  101.         return    loaded ? mult_f : EOF;    /* report error    */
  102.     case MALLOC_FAILURE:
  103.     case RLE_NO_SPACE:
  104.         prgmerr(0, "%s: Out of Memory! Trying to continue\n");
  105.         break;
  106.     case FATAL_FAILURE:
  107.         prgmerr(1, movie ? "Can't start movie, sorry ..." : " ");
  108.     }
  109.     }
  110.     }
  111. }
  112.