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 ***********************************************************/
28 extern long Counter(void);
32 int Read_GIF_to_Pixmaps(Display *display, Window window, char *filename,
33 Pixmap *pixmap, Pixmap *pixmap_mask)
35 Image *image, *image_mask;
36 XImageInfo *ximageinfo, *ximageinfo_mask;
47 if (!(image = gifLoad(filename)))
49 printf("Loading GIF image failed -- maybe no GIF...\n");
55 printf(" LOADING '%s' IN %.2f SECONDS\n",
56 filename, (float)(count2-count1)/1000.0);
62 printf("Sorry, GIFs with more than 256 colors are not supported.\n");
66 /* minimize colormap */
71 printf(" COMPRESSING IMAGE COLORMAP IN %.2f SECONDS\n",
72 (float)(count2-count1)/1000.0);
76 screen = DefaultScreen(display);
77 visual = DefaultVisual(display, screen);
78 depth = DefaultDepth(display, screen);
80 /* convert internal image structure to X11 XImage */
81 if (!(ximageinfo = imageToXImage(display, screen, visual, depth, image)))
83 fprintf(stderr, "Cannot convert Image to XImage.\n");
89 printf(" CONVERTING IMAGE TO XIMAGE IN %.2f SECONDS\n",
90 (float)(count2-count1)/1000.0);
94 if (ximageinfo->cmap != DefaultColormap(display, screen))
95 XSetWindowColormap(display, window, ximageinfo->cmap);
97 /* convert XImage to Pixmap */
98 if ((*pixmap = ximageToPixmap(display, window, ximageinfo)) == None)
100 fprintf(stderr, "Cannot convert XImage to Pixmap.\n");
106 printf(" CONVERTING IMAGE TO PIXMAP IN %.2f SECONDS\n",
107 (float)(count2-count1)/1000.0);
111 /* create mono image for masking */
112 image_mask = monochrome(image);
116 printf(" CONVERTING IMAGE TO MASK IN %.2f SECONDS\n",
117 (float)(count2-count1)/1000.0);
121 /* convert internal image structure to X11 XImage */
122 if (!(ximageinfo_mask = imageToXImage(display, screen, visual, depth,
125 fprintf(stderr, "Cannot convert Image to XImage.\n");
131 printf(" CONVERTING MASK TO XIMAGE IN %.2f SECONDS\n",
132 (float)(count2-count1)/1000.0);
136 /* convert XImage to Pixmap */
137 if ((*pixmap_mask = ximageToPixmap(display, window, ximageinfo_mask)) == None)
139 fprintf(stderr, "Cannot convert XImage to Pixmap.\n");
145 printf(" CONVERTING MASK TO PIXMAP IN %.2f SECONDS\n",
146 (float)(count2-count1)/1000.0);