1 /***********************************************************
2 * Rocks'n'Diamonds -- McDuffin Strikes Back! *
3 *----------------------------------------------------------*
4 * (c) 1995-98 Artsoft Entertainment *
8 * phone: ++49 +521 290471 *
9 * email: aeglos@valinor.owl.de *
10 *----------------------------------------------------------*
12 ***********************************************************/
17 /* extra colors to try allocating in private color maps to minimise flashing */
18 #define NOFLASH_COLORS 256
20 Image *monochrome(Image *cimage)
23 unsigned char *sp, *dp, *dp2; /* data pointers */
24 unsigned int spl; /* source pixel length in bytes */
25 unsigned int dll; /* destination line length in bytes */
26 Pixel color; /* pixel color */
27 unsigned int x, y; /* random counters */
32 printf("-->ERROR(monochrome)\n");
37 image = newBitImage(cimage->width, cimage->height);
40 dll = (image->width / 8) + (image->width % 8 ? 1 : 0);
45 for (y=0; y<cimage->height; y++)
47 for (x=0; x<cimage->width; x++)
49 dp2 = dp + (x / 8); /* dp + x/8 */
50 color = memToVal(sp, spl);
52 if (cimage->rgb.red[color] > 0x0000 ||
53 cimage->rgb.green[color] > 0x0000 ||
54 cimage->rgb.blue[color] > 0x0000)
59 *dp2 |= bitmap_pixel >> (x % 8);
63 dp += dll; /* next row */
69 static unsigned int *buildIndex(unsigned int width,
84 fzoom = (float)zoom / 100.0;
85 *rwidth = (unsigned int)(fzoom * width + 0.5);
87 index = (unsigned int *)checked_malloc(sizeof(unsigned int) * *rwidth);
88 for (a=0; a<*rwidth; a++)
91 *(index + a) = (unsigned int)((float)a / fzoom + 0.5);
98 Image *zoom(Image *oimage, unsigned int xzoom, unsigned int yzoom)
101 unsigned int *xindex, *yindex;
102 unsigned int xwidth, ywidth;
103 unsigned int x, y, xsrc, ysrc;
105 unsigned int srclinelen;
106 unsigned int destlinelen;
107 byte *srcline, *srcptr;
108 byte *destline, *destptr;
109 byte srcmask, destmask, bit;
112 if ((!xzoom || xzoom == 100) && (!yzoom || yzoom == 100))
116 printf(" Zooming image Y axis by %d%%...", yzoom);
118 printf(" Zooming image X axis by %d%%...", xzoom);
119 else if (xzoom == yzoom)
120 printf(" Zooming image by %d%%...", xzoom);
122 printf(" Zooming image X axis by %d%% and Y axis by %d%%...",
126 xindex = buildIndex(oimage->width, xzoom, &xwidth);
127 yindex = buildIndex(oimage->height, yzoom, &ywidth);
129 switch (oimage->type)
132 image = newBitImage(xwidth, ywidth);
133 for (x=0; x<oimage->rgb.used; x++)
135 *(image->rgb.red + x) = *(oimage->rgb.red + x);
136 *(image->rgb.green + x) = *(oimage->rgb.green + x);
137 *(image->rgb.blue + x) = *(oimage->rgb.blue + x);
139 image->rgb.used = oimage->rgb.used;
140 destline = image->data;
141 destlinelen = (xwidth / 8) + (xwidth % 8 ? 1 : 0);
142 srcline = oimage->data;
143 srclinelen = (oimage->width / 8) + (oimage->width % 8 ? 1 : 0);
144 for (y=0, ysrc=*(yindex + y); y<ywidth; y++)
146 while (ysrc != *(yindex + y))
149 srcline += srclinelen;
155 bit = srcmask & *srcptr;
156 for (x=0, xsrc=*(xindex + x); x<xwidth; x++)
158 if (xsrc != *(xindex + x))
163 if (!(srcmask >>= 1))
169 while (xsrc != *(xindex + x));
171 bit = srcmask & *srcptr;
174 *destptr |= destmask;
175 if (!(destmask >>= 1))
181 destline += destlinelen;
186 image = newRGBImage(xwidth, ywidth, oimage->depth);
187 for (x=0; x<oimage->rgb.used; x++)
189 *(image->rgb.red + x) = *(oimage->rgb.red + x);
190 *(image->rgb.green + x) = *(oimage->rgb.green + x);
191 *(image->rgb.blue + x) = *(oimage->rgb.blue + x);
193 image->rgb.used = oimage->rgb.used;
195 pixlen = oimage->pixlen;
196 destptr = image->data;
197 srcline = oimage->data;
198 srclinelen = oimage->width * pixlen;
199 for (y=0, ysrc=*(yindex + y); y<ywidth; y++)
201 while (ysrc != *(yindex + y))
204 srcline += srclinelen;
208 value = memToVal(srcptr, image->pixlen);
210 for (x=0, xsrc=*(xindex + x); x<xwidth; x++)
212 if (xsrc != *(xindex + x))
219 while (xsrc != *(xindex + x));
220 value = memToVal(srcptr, 1);
222 valToMem(value, destptr, 1);
234 free((byte *)xindex);
235 free((byte *)yindex);
242 void compress(Image *image)
244 unsigned char *used, fast[32][32][32];
245 unsigned int dmask; /* Depth mask protection */
247 unsigned int next_index;
248 Intensity *red = image->rgb.red,
249 *green = image->rgb.green,
250 *blue = image->rgb.blue;
252 unsigned int x, y, badcount = 0, dupcount = 0, unusedcount = 0;
253 unsigned char *pixptr, *pixend;
255 if (!RGBP(image) || image->rgb.compressed)
258 used = (unsigned char *)checked_calloc(sizeof(unsigned char) * depthToColors(image->depth));
259 dmask = (1 << image->depth) -1; /* Mask any illegal bits for that depth */
260 map = (Pixel *)checked_calloc(sizeof(Pixel) * depthToColors(image->depth));
262 /* init fast duplicate check table */
268 /* do pass 1 through the image to check index usage */
270 pixptr = image->data;
271 pixend = pixptr + (image->height * image->width);
272 for(;pixptr < pixend; pixptr++)
273 used[(*pixptr) & dmask] = 1;
275 /* count the bad pixels */
276 for (x = image->rgb.used; x < depthToColors(image->depth); x++)
280 /* figure out duplicates and unuseds, and create the new mapping */
282 for (x = 0; x < image->rgb.used; x++)
287 continue; /* delete this index */
290 /* check for duplicate */
294 if (fast[r>>11][g>>11][b>>11]) /* if matches fast check */
296 /* then do a linear search */
297 for (y = x+1; y < image->rgb.used; y++)
299 if (r == red[y] && g == green[y] && b == blue[y])
302 if (y < image->rgb.used) /* found match */
306 continue; /* delete this index */
308 fast[r>>11][g>>11][b>>11] = 1;
310 /* will map to this index */
315 /* change the image pixels */
316 pixptr = image->data;
317 pixend = pixptr + (image->height * image->width);
318 for(;pixptr < pixend; pixptr++)
319 *pixptr = map[(*pixptr) & dmask];
321 /* change the colormap */
322 for (x = 0; x < image->rgb.used; x++)
326 red[map[x]] = red[x];
327 green[map[x]] = green[x];
328 blue[map[x]] = blue[x];
330 image->rgb.used = next_index;
340 printf("%d out-of-range pixels, ", badcount);
342 if (!unusedcount && !dupcount)
343 printf("no improvment\n");
347 printf("%d duplicate%s and %d unused color%s removed...",
348 dupcount, (dupcount == 1 ? "" : "s"),
349 unusedcount, (unusedcount == 1 ? "" : "s"));
350 printf("%d unique color%s\n",
351 next_index, (next_index == 1 ? "" : "s"));
357 image->rgb.compressed = TRUE; /* don't do it again */
363 Pixmap XImage_to_Pixmap(Display *display, Window parent,
364 XImageInfo *ximageinfo)
368 pixmap = XCreatePixmap(display, parent,
369 ximageinfo->ximage->width, ximageinfo->ximage->height,
372 ximageinfo->drawable = pixmap;
374 XImage_to_Drawable(ximageinfo, 0, 0, 0, 0,
375 ximageinfo->ximage->width, ximageinfo->ximage->height);
379 /* find the best pixmap depth supported by the server for a particular
380 * visual and return that depth.
382 * this is complicated by R3's lack of XListPixmapFormats so we fake it
383 * by looking at the structure ourselves.
386 static unsigned int bitsPerPixelAtDepth(Display *display, int screen,
389 XPixmapFormatValues *xf;
392 xf = XListPixmapFormats(display, &nxf);
393 for (a = 0; a < nxf; a++)
395 if (xf[a].depth == depth)
398 bpp = xf[a].bits_per_pixel;
400 return (unsigned int) bpp;
405 /* this should never happen; if it does, we're in trouble
408 fprintf(stderr, "bitsPerPixelAtDepth: Can't find pixmap depth info!\n");
412 XImageInfo *Image_to_XImage(Display *display, int screen, Visual *visual,
413 unsigned int ddepth, Image *image)
415 static XColor xcolor_private[NOFLASH_COLORS];
416 static int colorcell_used[NOFLASH_COLORS];
417 static Colormap global_cmap = 0;
418 static Pixel *global_cmap_index;
419 static int num_cmap_entries, free_cmap_entries;
420 static private_cmap = FALSE;
421 Pixel *redvalue, *greenvalue, *bluevalue;
422 unsigned int a, c=0, x, y, linelen, dpixlen, dbits;
425 XImageInfo *ximageinfo;
429 if (visual == DefaultVisual(display, screen))
430 global_cmap = DefaultColormap(display, screen);
433 global_cmap = XCreateColormap(display, RootWindow(display, screen),
439 xcolor.flags = DoRed | DoGreen | DoBlue;
440 redvalue = greenvalue = bluevalue = NULL;
441 ximageinfo = (XImageInfo *)checked_malloc(sizeof(XImageInfo));
442 ximageinfo->display = display;
443 ximageinfo->screen = screen;
444 ximageinfo->depth = 0;
445 ximageinfo->drawable = None;
446 ximageinfo->index = NULL;
447 ximageinfo->rootimage = FALSE;
448 ximageinfo->foreground = ximageinfo->background= 0;
449 ximageinfo->gc = NULL;
450 ximageinfo->ximage = NULL;
452 switch (visual->class)
458 unsigned int redcolors, greencolors, bluecolors;
459 unsigned int redstep, greenstep, bluestep;
460 unsigned int redbottom, greenbottom, bluebottom;
461 unsigned int redtop, greentop, bluetop;
463 redvalue = (Pixel *)checked_malloc(sizeof(Pixel) * 256);
464 greenvalue = (Pixel *)checked_malloc(sizeof(Pixel) * 256);
465 bluevalue = (Pixel *)checked_malloc(sizeof(Pixel) * 256);
467 ximageinfo->cmap = global_cmap;
469 retry_direct: /* tag we hit if a DirectColor allocation fails on
470 * default colormap */
472 /* calculate number of distinct colors in each band
475 redcolors = greencolors = bluecolors = 1;
476 for (pixval=1; pixval; pixval <<= 1)
478 if (pixval & visual->red_mask)
480 if (pixval & visual->green_mask)
482 if (pixval & visual->blue_mask)
489 if ((redcolors > visual->map_entries) ||
490 (greencolors > visual->map_entries) ||
491 (bluecolors > visual->map_entries))
493 fprintf(stderr, "Warning: inconsistency in color information (this may be ugly)\n");
496 redstep = 256 / redcolors;
497 greenstep = 256 / greencolors;
498 bluestep = 256 / bluecolors;
499 redbottom = greenbottom = bluebottom = 0;
500 redtop = greentop = bluetop = 0;
501 for (a=0; a<visual->map_entries; a++)
504 redtop = redbottom + redstep;
505 if (greenbottom < 256)
506 greentop = greenbottom + greenstep;
507 if (bluebottom < 256)
508 bluetop = bluebottom + bluestep;
510 xcolor.red = (redtop - 1) << 8;
511 xcolor.green = (greentop - 1) << 8;
512 xcolor.blue = (bluetop - 1) << 8;
513 if (!XAllocColor(display, ximageinfo->cmap, &xcolor))
515 /* if an allocation fails for a DirectColor default visual then
516 * we should create a private colormap and try again.
519 if ((visual->class == DirectColor) &&
520 (visual == DefaultVisual(display, screen)))
522 global_cmap = XCopyColormapAndFree(display, global_cmap);
523 ximageinfo->cmap = global_cmap;
529 /* something completely unexpected happened
532 fprintf(stderr, "imageToXImage: XAllocColor failed on a TrueColor/Directcolor visual\n");
533 free((byte *)redvalue);
534 free((byte *)greenvalue);
535 free((byte *)bluevalue);
536 free((byte *)ximageinfo);
540 /* fill in pixel values for each band at this intensity
543 while ((redbottom < 256) && (redbottom < redtop))
544 redvalue[redbottom++] = xcolor.pixel & visual->red_mask;
545 while ((greenbottom < 256) && (greenbottom < greentop))
546 greenvalue[greenbottom++] = xcolor.pixel & visual->green_mask;
547 while ((bluebottom < 256) && (bluebottom < bluetop))
548 bluevalue[bluebottom++] = xcolor.pixel & visual->blue_mask;
555 ximageinfo->cmap = global_cmap;
557 (Pixel *)checked_malloc(sizeof(Pixel) * image->rgb.used);
559 for (a=0; a<image->rgb.used; a++)
566 xcolor.red = *(image->rgb.red + a);
567 xcolor.green = *(image->rgb.green + a);
568 xcolor.blue = *(image->rgb.blue + a);
570 /* look if this color already exists in our colormap */
571 if (!XAllocColor(display, ximageinfo->cmap, &xcolor))
576 printf("switching to private colormap...\n");
579 /* we just filled up the default colormap -- get a private one
580 which contains all already allocated colors */
582 global_cmap = XCopyColormapAndFree(display, global_cmap);
583 ximageinfo->cmap = global_cmap;
586 /* allocate the rest of the color cells read/write */
588 (Pixel *)checked_malloc(sizeof(Pixel) * NOFLASH_COLORS);
589 for (i=0; i<NOFLASH_COLORS; i++)
590 if (!XAllocColorCells(display, global_cmap, FALSE, NULL, 0,
591 global_cmap_index + i, 1))
593 num_cmap_entries = free_cmap_entries = i;
596 printf("We've got %d free colormap entries.\n", free_cmap_entries);
599 /* to minimize colormap flashing, copy default colors and try
600 to keep them as near as possible to the old values */
602 for(i=0; i<num_cmap_entries; i++)
604 xcolor2.pixel = *(global_cmap_index + i);
605 XQueryColor(display, DefaultColormap(display, screen), &xcolor2);
606 XStoreColor(display, global_cmap, &xcolor2);
607 xcolor_private[xcolor2.pixel] = xcolor2;
608 colorcell_used[xcolor2.pixel] = FALSE;
611 /* now we have the default colormap private: all colors we
612 successfully allocated so far are read-only, which is okay,
613 because we don't want to change them anymore -- if we need
614 an existing color again, we get it by XAllocColor; all other
615 colors are read/write and we can set them by XStoreColor,
616 but we will try to overwrite those color cells with our new
617 color which are as close as possible to our new color */
620 /* look for an existing default color close the one we want */
627 for (i=num_cmap_entries-1; i>=0; i--)
629 xcolor2.pixel = *(global_cmap_index + i);
630 xcolor2 = xcolor_private[xcolor2.pixel];
632 if (colorcell_used[xcolor2.pixel])
635 if ((xcolor.red & mask) == (xcolor2.red & mask) &&
636 (xcolor.green & mask) == (xcolor2.green & mask) &&
637 (xcolor.blue & mask) == (xcolor2.blue & mask))
640 printf("replacing color cell %ld with a close color\n",
651 mask = (mask << 1) & 0xffff;
654 if (!color_found) /* no more free color cells */
656 printf("Sorry, cannot allocate enough colors!\n");
660 xcolor.pixel = xcolor2.pixel;
661 xcolor_private[xcolor.pixel] = xcolor;
662 colorcell_used[xcolor.pixel] = TRUE;
663 XStoreColor(display, ximageinfo->cmap, &xcolor);
667 *(ximageinfo->index + a) = xcolor.pixel;
671 printf("still %d free colormap entries\n", free_cmap_entries);
674 ximageinfo->no = a; /* number of pixels allocated for this image */
678 printf("Sorry, only DirectColor, TrueColor and PseudoColor supported\n");
683 /* create an XImage and related colormap based on the image type
688 printf(" Building XImage...");
698 /* we copy the data to be more consistent
701 linelen = ((image->width + 7) / 8);
702 data= checked_malloc(linelen * image->height);
704 memcpy((char *)data, (char *)image->data, linelen * image->height);
706 gcv.function= GXcopy;
707 ximageinfo->ximage= XCreateImage(display, visual, 1, XYBitmap,
708 0, (char *)data, image->width,
712 /* use this if you want to use the bitmap as a mask */
713 ximageinfo->depth = image->depth;
715 if(visual->class == DirectColor || visual->class == TrueColor)
718 dbits= bitsPerPixelAtDepth(display, screen, ddepth);
719 dpixlen= (dbits + 7) / 8;
720 pixval= redvalue[image->rgb.red[0] >> 8] |
721 greenvalue[image->rgb.green[0] >> 8] |
722 bluevalue[image->rgb.blue[0] >> 8];
723 ximageinfo->background = pixval;
724 pixval= redvalue[image->rgb.red[1] >> 8] |
725 greenvalue[image->rgb.green[1] >> 8] |
726 bluevalue[image->rgb.blue[1] >> 8];
727 ximageinfo->foreground = pixval;
729 else /* Not Direct or True Color */
731 ximageinfo->foreground = BlackPixel(display, screen);
732 ximageinfo->background = WhitePixel(display, screen);
734 ximageinfo->ximage->bitmap_bit_order= MSBFirst;
735 ximageinfo->ximage->byte_order= MSBFirst;
742 /* modify image data to match visual and colormap
745 byte *data, *destptr, *srcptr;
747 dbits = bitsPerPixelAtDepth(display, screen, ddepth);/* bits per pixel */
748 dpixlen = (dbits + 7) / 8; /* bytes per pixel */
750 ximageinfo->ximage = XCreateImage(display, visual, ddepth, ZPixmap, 0,
751 NULL, image->width, image->height,
752 8, image->width * dpixlen);
754 data = (byte *)checked_malloc(image->width * image->height * dpixlen);
755 ximageinfo->depth = ddepth;
756 ximageinfo->ximage->data = (char *)data;
757 ximageinfo->ximage->byte_order = MSBFirst;
758 srcptr = image->data;
761 switch (visual->class)
768 for (y=0; y<image->height; y++)
770 for (x=0; x<image->width; x++)
772 pixval = memToVal(srcptr, 1);
773 pixval = redvalue[image->rgb.red[pixval] >> 8] |
774 greenvalue[image->rgb.green[pixval] >> 8] |
775 bluevalue[image->rgb.blue[pixval] >> 8];
776 valToMem(pixval, destptr, dpixlen);
786 if (dpixlen == 1) /* most common */
788 for (y=0; y<image->height; y++)
790 for (x=0; x<image->width; x++)
792 *destptr = ximageinfo->index[c + *srcptr];
798 else /* less common */
800 for (y=0; y<image->height; y++)
802 for (x=0; x<image->width; x++)
804 register unsigned long temp;
805 temp = memToVal(srcptr, 1);
806 valToMem(ximageinfo->index[c + temp], destptr, dpixlen);
824 free((byte *)redvalue);
825 free((byte *)greenvalue);
826 free((byte *)bluevalue);
832 /* Given an XImage and a drawable, move a rectangle from the Ximage
836 void XImage_to_Drawable(XImageInfo *ximageinfo,
837 int src_x, int src_y, int dst_x, int dst_y,
838 unsigned int w, unsigned int h)
842 /* build and cache the GC
847 gcv.function = GXcopy;
848 if (ximageinfo->ximage->depth == 1)
850 gcv.foreground = ximageinfo->foreground;
851 gcv.background = ximageinfo->background;
852 ximageinfo->gc = XCreateGC(ximageinfo->display, ximageinfo->drawable,
853 GCFunction | GCForeground | GCBackground,
857 ximageinfo->gc = XCreateGC(ximageinfo->display, ximageinfo->drawable,
861 XPutImage(ximageinfo->display, ximageinfo->drawable, ximageinfo->gc,
862 ximageinfo->ximage, src_x, src_y, dst_x, dst_y, w, h);
865 /* free up anything cached in the local Ximage structure.
868 void freeXImage(Image *image, XImageInfo *ximageinfo)
870 if (ximageinfo->index != NULL) /* if we allocated colors */
872 if (ximageinfo->no > 0 && !ximageinfo->rootimage) /* don't free root colors */
873 XFreeColors(ximageinfo->display, ximageinfo->cmap, ximageinfo->index,
875 free(ximageinfo->index);
878 XFreeGC(ximageinfo->display, ximageinfo->gc);
879 free((byte *)ximageinfo->ximage->data);
880 ximageinfo->ximage->data= NULL;
881 XDestroyImage(ximageinfo->ximage);
882 free((byte *)ximageinfo);
883 /* should we free private color map to ??? */
888 /* this table is useful for quick conversions between depth and ncolors
891 unsigned long DepthToColorsTable[] =
920 void newRGBMapData(RGBMap *rgb, unsigned int size)
924 rgb->compressed = FALSE;
925 rgb->red = (Intensity *)checked_malloc(sizeof(Intensity) * size);
926 rgb->green = (Intensity *)checked_malloc(sizeof(Intensity) * size);
927 rgb->blue = (Intensity *)checked_malloc(sizeof(Intensity) * size);
930 void freeRGBMapData(RGBMap *rgb)
932 free((byte *)rgb->red);
933 free((byte *)rgb->green);
934 free((byte *)rgb->blue);
937 Image *newBitImage(unsigned int width, unsigned int height)
940 unsigned int linelen;
942 image = (Image *)checked_malloc(sizeof(Image));
943 image->type = IBITMAP;
944 newRGBMapData(&(image->rgb), (unsigned int)2);
945 *(image->rgb.red)= *(image->rgb.green) = *(image->rgb.blue)= 65535;
946 *(image->rgb.red + 1)= *(image->rgb.green + 1) = *(image->rgb.blue + 1)= 0;
948 image->width = width;
949 image->height = height;
951 linelen = ((width + 7) / 8);
952 image->data = (unsigned char *)checked_calloc(linelen * height);
956 Image *newRGBImage(unsigned int width, unsigned int height, unsigned int depth)
959 unsigned int pixlen, numcolors;
961 if (depth == 0) /* special case for `zero' depth image, which is */
962 depth = 1; /* sometimes interpreted as `one color' */
963 pixlen = ((depth+7) / 8);
964 numcolors = depthToColors(depth);
965 image = (Image *)checked_malloc(sizeof(Image));
967 newRGBMapData(&(image->rgb), numcolors);
968 image->width = width;
969 image->height = height;
970 image->depth = depth;
971 image->pixlen = pixlen;
972 image->data = (unsigned char *)checked_malloc(width * height * pixlen);
976 void freeImageData(Image *image)
978 freeRGBMapData(&(image->rgb));
982 void freeImage(Image *image)
984 freeImageData(image);
988 /* ------------------------------------------------------------------------- */
998 int Read_PCX_to_Pixmaps(Display *display, Window window, char *filename,
999 Pixmap *pixmap, Pixmap *pixmap_mask)
1001 Image *image, *image_mask;
1002 XImageInfo *ximageinfo, *ximageinfo_mask;
1008 long count1, count2;
1013 if (!(image = Read_PCX_to_Image(filename)))
1015 printf("Loading GIF image failed -- maybe no GIF...\n");
1021 printf(" LOADING '%s' IN %.2f SECONDS\n",
1022 filename, (float)(count2-count1)/1000.0);
1026 if (image->depth > 8)
1028 printf("Sorry, GIFs with more than 256 colors are not supported.\n");
1032 /* minimize colormap */
1037 printf(" COMPRESSING IMAGE COLORMAP IN %.2f SECONDS\n",
1038 (float)(count2-count1)/1000.0);
1042 screen = DefaultScreen(display);
1043 visual = DefaultVisual(display, screen);
1044 depth = DefaultDepth(display, screen);
1046 /* convert internal image structure to X11 XImage */
1047 if (!(ximageinfo = Image_to_XImage(display, screen, visual, depth, image)))
1049 fprintf(stderr, "Cannot convert Image to XImage.\n");
1055 printf(" CONVERTING IMAGE TO XIMAGE IN %.2f SECONDS\n",
1056 (float)(count2-count1)/1000.0);
1060 if (ximageinfo->cmap != DefaultColormap(display, screen))
1061 XSetWindowColormap(display, window, ximageinfo->cmap);
1063 /* convert XImage to Pixmap */
1064 if ((*pixmap = XImage_to_Pixmap(display, window, ximageinfo)) == None)
1066 fprintf(stderr, "Cannot convert XImage to Pixmap.\n");
1072 printf(" CONVERTING IMAGE TO PIXMAP IN %.2f SECONDS\n",
1073 (float)(count2-count1)/1000.0);
1077 /* create mono image for masking */
1078 image_mask = monochrome(image);
1082 printf(" CONVERTING IMAGE TO MASK IN %.2f SECONDS\n",
1083 (float)(count2-count1)/1000.0);
1087 /* convert internal image structure to X11 XImage */
1088 if (!(ximageinfo_mask = Image_to_XImage(display, screen, visual, depth,
1091 fprintf(stderr, "Cannot convert Image to XImage.\n");
1097 printf(" CONVERTING MASK TO XIMAGE IN %.2f SECONDS\n",
1098 (float)(count2-count1)/1000.0);
1102 /* convert XImage to Pixmap */
1103 if ((*pixmap_mask = XImage_to_Pixmap(display, window, ximageinfo_mask)) == None)
1105 fprintf(stderr, "Cannot convert XImage to Pixmap.\n");
1111 printf(" CONVERTING MASK TO PIXMAP IN %.2f SECONDS\n",
1112 (float)(count2-count1)/1000.0);
1116 return(GIF_Success);