home *** CD-ROM | disk | FTP | other *** search
- /* LoaD_IMAGE . C
- #
- % Copyright (c) see included header files
- %
- % AUTHOR: Jin Guojun - LBL 10/1/91
- */
-
- #include "function.h"
-
- extern int rw_set;
-
- image_information*
- dup_mv_hd(img, previous)
- image_information* img, *previous;
- {
- #define cpl1 sizeof(int) * 18
- #define cpl2 sizeof(int) * 11
- #define INHERIT(thing) img->thing = previous->thing
- memcpy(&img->colormap, &previous->colormap, cpl1);
- memcpy(&img->dpy_depth, &previous->dpy_depth, cpl1);
- memcpy(&img->in_type, &previous->in_type, cpl2);
- memcpy(&img->map_scanline, &previous->map_scanline, cpl2);
- if (stingy_flag) img->image = NULL;
- INHERIT(icn_pixmap);
- INHERIT(divN);
- INHERIT(modN);
- INHERIT(dm16);
- INHERIT(pixel_table);
- INHERIT(lvls);
- INHERIT(lvls_squared);
- INHERIT(visual_class);
- #undef INHERIT
- return previous;
- }
-
- LoadGXImage(num_images, parent, pic, movie, win_geom, still_win)
- int *num_images;
- Image *parent, ***pic;
- char *win_geom;
- {
- int loaded=0, rle_cnt=0, status, vbs=0;
- Loop {
- Image *img, *previous_img=NULL;
-
- vbs += verify_buffer_size(pic, -sizeof(**pic), *num_images+1, No);
- if (!*pic) prgmerr(RLE_NO_SPACE, "out of memory!");
- if (vbs) (*pic)[*num_images] = NULL;
- if (still_win) for (status=*num_images; status--;)
- if (!strcmp((*pic)[status]->name, parent->name)) break;
- if ((!still_win || status < 1) && !(*pic)[*num_images]) {
- img = (*pic)[*num_images] = (Image*)ZALLOC(1, sizeof(*img), "img");
-
- img->visual_class = parent->visual_class;
- init_img_info(img, Dpy, RLE, parent->dpy);
-
- /* we need pixmaps for movie mode */
- img->pixmap_failed = parent->pixmap_failed;
- img->gamma = parent->gamma;
- img->name = parent->name;
- img->IN_FP = parent->IN_FP;
- } else img = (*pic)[status], --*num_images, previous_img = img;
- if (movie && *num_images)
- previous_img = dup_mv_hd(img, (*pic)[*num_images-1]);
- else init_img_flag(img), multi_hd = 0;
-
- if (rle_cnt) /* may be a sequence image */
- multi_hd++;
- img->frames = rle_cnt;
-
- status = get_pic(*num_images, win_geom, previous_img, *pic, 1);
-
- {
- register int mult_f = img->frames>1, i_t = img->in_type;
-
- switch (status) {
- case SUCCESS:
- loaded = rw_set = ++*num_images;
- if (i_t!=HIPS && i_t!=FITS && i_t!=JPEG || movie) {
- rle_cnt++;
- continue;
- }
- if (mult_f) {
- verify_buffer_size(&img->data, -img->dpy_channels,
- img->width*img->height << 1, "realloc MultiF");
- (*img->std_swif)(FI_RLOAD_BUF, img, img->data +
- img->width*img->height*img->dpy_channels, OsameI);
- if (!tuner_flag)
- img->scan_data = img->data;
- }
- img->fn++;
-
- case RLE_EMPTY:
- case RLE_EOF:
- case EOF: /* = RLE_NOT_RLE */
- if ((status==RLE_NOT_RLE || !rle_cnt) && (DEBUGANY | verbose))
- rle_get_error(status, Progname, img->name);
- EOF_case: if (!mult_f) fclose(img->IN_FP);
- if (rle_cnt)
- free (img /* == pic[*num_images] */),
- (*pic)[*num_images] = NULL;
- return loaded ? mult_f : EOF; /* report error */
- case MALLOC_FAILURE:
- case RLE_NO_SPACE:
- prgmerr(0, "%s: Out of Memory! Trying to continue\n");
- break;
- case FATAL_FAILURE:
- prgmerr(1, movie ? "Can't start movie, sorry ..." : " ");
- }
- }
- }
- }
-