+ g_object_unref (base_pb);
+}
+
+
+static guint32
+parse_color (const char *s)
+{
+ static const char hex[128] =
+ {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 0, 0, 0, 0, 0,
+ 0, 10,11,12,13,14,15,0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 10,11,12,13,14,15,0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
+
+ unsigned char r=0, g=0, b=0;
+
+ if (!strcasecmp (s, "black")) ;
+ else if (!strcasecmp (s, "white")) r = g = b = 0xFF;
+ else if (!strcasecmp (s, "red")) r = 0xFF;
+ else if (!strcasecmp (s, "green")) g = 0xFF;
+ else if (!strcasecmp (s, "blue")) b = 0xFF;
+ else
+ {
+ if (*s != '#' || strlen(s) != 7)
+ {
+ fprintf (stderr, "%s: unparsable color: \"%s\"\n", progname, s);
+ exit (1);
+ }
+ s++;
+ r = (hex[(int) s[0]] << 4) | hex[(int) s[1]], s += 2;
+ g = (hex[(int) s[0]] << 4) | hex[(int) s[1]], s += 2;
+ b = (hex[(int) s[0]] << 4) | hex[(int) s[1]], s += 2;
+ }
+
+ return (r << 16) | (g << 8) | b;
+}
+
+
+static void
+create (const char *color,
+ int w, int h,
+ const char *file)
+{
+ int i;
+ GdkPixbuf *pb;
+ guint32 pixel = parse_color (color);
+ unsigned char *bytes = malloc (w * h * 3);
+ if (!bytes) abort();
+ for (i = 0; i < w * h * 3; i += 3)
+ {
+ bytes[i] = 0xFF & (pixel >> 16);
+ bytes[i+1] = 0xFF & (pixel >> 8);
+ bytes[i+2] = 0xFF & (pixel);
+ }
+
+ pb = gdk_pixbuf_new_from_data (bytes, GDK_COLORSPACE_RGB,
+ FALSE, 8, /* alpha, sample size */
+ w, h,
+ w * 3, /* rowstride */
+ NULL, 0);
+ if (!pb) abort();
+ write_pixbuf (pb, file);
+ g_object_unref (pb);
+ free (bytes);