+#if defined (HAVE_X_WINDOWS)
+ static unsigned char swap_nibble[16]
+ = { 0x0, 0x8, 0x4, 0xc, /* 0000 1000 0100 1100 */
+ 0x2, 0xa, 0x6, 0xe, /* 0010 1010 0110 1110 */
+ 0x1, 0x9, 0x5, 0xd, /* 0001 1001 0101 1101 */
+ 0x3, 0xb, 0x7, 0xf }; /* 0011 1011 0111 1111 */
+ unsigned short *bits = fb->bits;
+ int j;
+
+ if (fb->width <= 8)
+ {
+ unsigned char *cbits = (unsigned char *)fb->bits;
+ for (j = 0; j < fb->height; j++)
+ {
+ unsigned short b = *bits++;
+ unsigned char c;
+ c = (unsigned char)((swap_nibble[b & 0xf] << 4)
+ | (swap_nibble[(b>>4) & 0xf]));
+ *cbits++ = (c >> (8 - fb->width));
+ }
+ }
+ else
+ {
+ for (j = 0; j < fb->height; j++)
+ {
+ unsigned short b = *bits;
+ b = (unsigned short)((swap_nibble[b & 0xf] << 12)
+ | (swap_nibble[(b>>4) & 0xf] << 8)
+ | (swap_nibble[(b>>8) & 0xf] << 4)
+ | (swap_nibble[(b>>12) & 0xf]));
+ *bits++ = (b >> (16 - fb->width));
+ }
+ }
+#endif /* HAVE_X_WINDOWS */
+
+#if defined (MAC_OS) && defined (WORDS_BIG_ENDIAN)
+ unsigned short *bits = fb->bits;