$NetBSD: patch-ao,v 1.1 1999/06/07 20:47:25 tron Exp $

--- src/pixmaps.c.orig	Tue Jun 25 23:53:50 1996
+++ src/pixmaps.c	Mon Jun  7 22:34:53 1999
@@ -685,6 +685,12 @@
 		bshift = highbit(theVisual->blue_mask) - 7;
 		bmap_order = BitmapBitOrder(XtDisplay(wid));
 
+		newimage = XCreateImage(XtDisplay(wid),
+			DefaultVisual(XtDisplay(wid),
+				DefaultScreen(XtDisplay(wid))),
+			depth, ZPixmap, 0, (char *)bit_data,
+			width, height, 8, 0);
+
 		bitp = bit_data;
 		datap = data;
 		for (w = size; w > 0; w--)
@@ -698,7 +704,10 @@
 
 			if (bmap_order == MSBFirst)
 			{
-				*bitp++ = (unsigned char)((c >> 24) & 0xff);
+				if (newimage->bits_per_pixel == 32)
+				{
+					*bitp++ = (unsigned char)((c >> 24) & 0xff);
+				}
 				*bitp++ = (unsigned char)((c >> 16) & 0xff);
 				*bitp++ = (unsigned char)((c >> 8) & 0xff);
 				*bitp++ = (unsigned char)(c & 0xff);
@@ -708,15 +717,13 @@
 				*bitp++ = (unsigned char)(c & 0xff);
 				*bitp++ = (unsigned char)((c >> 8) & 0xff);
 				*bitp++ = (unsigned char)((c >> 16) & 0xff);
-				*bitp++ = (unsigned char)((c >> 24) & 0xff);
+				if (newimage->bits_per_pixel == 32)
+				{
+					*bitp++ = (unsigned char)((c >> 24) & 0xff);
+				}
 			}
 		}
 
-		newimage = XCreateImage(XtDisplay(wid),
-			DefaultVisual(XtDisplay(wid),
-				DefaultScreen(XtDisplay(wid))),
-			depth, ZPixmap, 0, (char *)bit_data,
-			width, height, 32, 0);
 		break;
 	    default:
 		newimage = NULL;
