+#else /* !XMU */
+ {
+ fprintf (stderr,
+ "%s: your vendor doesn't ship the standard Xmu library.\n",
+ progname);
+ fprintf (stderr, "\tWe can't load XBM files without it.\n");
+ exit (1);
+ }
+#endif /* !XMU */
+}
+
+
+static Pixmap
+read_screen (Display *dpy, Window window, int *widthP, int *heightP)
+{
+ Pixmap p;
+ XWindowAttributes xgwa;
+ XGCValues gcv;
+ GC gc;
+ XGetWindowAttributes (dpy, window, &xgwa);
+ *widthP = xgwa.width;
+ *heightP = xgwa.height;
+
+ grab_screen_image(xgwa.screen, window);
+ p = XCreatePixmap(dpy, window, *widthP, *heightP, xgwa.depth);
+ gcv.function = GXcopy;
+ gc = XCreateGC (dpy, window, GCFunction, &gcv);
+ XCopyArea (dpy, window, p, gc, 0, 0, *widthP, *heightP, 0, 0);
+
+ /* Reset the window's background color... */
+ XSetWindowBackground (dpy, window,
+ get_pixel_resource ("background", "Background",
+ dpy, xgwa.colormap));
+ XCopyArea (dpy, p, window, gc, 0, 0, *widthP, *heightP, 0, 0);
+ XFreeGC (dpy, gc);
+
+ return p;
+}
+
+
+static int
+to_pow2(int n, Bool up)
+{
+ /* sizeof(Dimension) == 2. */
+ int powers_of_2[] = { 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024,
+ 2048, 4096, 8192, 16384, 32768, 65536 };
+ int i = 0;
+ if (n > 65536) size = 65536;
+ while (n >= powers_of_2[i]) i++;
+ if (n == powers_of_2[i-1])
+ return n;
+ else
+ return powers_of_2[up ? i : i-1];