1 /***********************************************************
2 * Rocks'n'Diamonds -- McDuffin Strikes Back! *
3 *----------------------------------------------------------*
4 * ©1995 Artsoft Development *
6 * 33659 Bielefeld-Senne *
7 * Telefon: (0521) 493245 *
8 * eMail: aeglos@valinor.owl.de *
9 * aeglos@uni-paderborn.de *
10 * q99492@pbhrzx.uni-paderborn.de *
11 *----------------------------------------------------------*
13 ***********************************************************/
26 extern long Counter(void);
30 int Read_GIF_to_Pixmaps(Display *display, Window window, char *filename,
31 Pixmap *pixmap, Pixmap *pixmap_mask)
33 Image *image, *image_mask;
34 XImageInfo *ximageinfo, *ximageinfo_mask;
45 if (!(image = gifLoad(filename)))
47 printf("Loading GIF image failed -- maybe no GIF...\n");
53 printf(" LOADING '%s' IN %.2f SECONDS\n",
54 filename, (float)(count2-count1)/100.0);
60 printf("Sorry, GIFs with more than 256 colors are not supported.\n");
64 /* minimize colormap */
69 printf(" COMPRESSING IMAGE COLORMAP IN %.2f SECONDS\n",
70 (float)(count2-count1)/100.0);
74 screen = DefaultScreen(display);
75 visual = DefaultVisual(display, screen);
76 depth = DefaultDepth(display, screen);
78 /* convert internal image structure to X11 XImage */
79 if (!(ximageinfo = imageToXImage(display, screen, visual, depth, image)))
81 fprintf(stderr, "Cannot convert Image to XImage.\n");
87 printf(" CONVERTING IMAGE TO XIMAGE IN %.2f SECONDS\n",
88 (float)(count2-count1)/100.0);
92 if (ximageinfo->cmap != DefaultColormap(display, screen))
93 XSetWindowColormap(display, window, ximageinfo->cmap);
95 /* convert XImage to Pixmap */
96 if ((*pixmap = ximageToPixmap(display, window, ximageinfo)) == None)
98 fprintf(stderr, "Cannot convert XImage to Pixmap.\n");
104 printf(" CONVERTING IMAGE TO PIXMAP IN %.2f SECONDS\n",
105 (float)(count2-count1)/100.0);
109 /* create mono image for masking */
110 image_mask = monochrome(image);
114 printf(" CONVERTING IMAGE TO MASK IN %.2f SECONDS\n",
115 (float)(count2-count1)/100.0);
119 /* convert internal image structure to X11 XImage */
120 if (!(ximageinfo_mask = imageToXImage(display, screen, visual, depth,
123 fprintf(stderr, "Cannot convert Image to XImage.\n");
129 printf(" CONVERTING MASK TO XIMAGE IN %.2f SECONDS\n",
130 (float)(count2-count1)/100.0);
134 /* convert XImage to Pixmap */
135 if ((*pixmap_mask = ximageToPixmap(display, window, ximageinfo_mask)) == None)
137 fprintf(stderr, "Cannot convert XImage to Pixmap.\n");
143 printf(" CONVERTING MASK TO PIXMAP IN %.2f SECONDS\n",
144 (float)(count2-count1)/100.0);