diff src/glyphs-x.c @ 225:12579d965149 r20-4b11

Import from CVS: tag r20-4b11
author cvs
date Mon, 13 Aug 2007 10:11:40 +0200
parents 2c611d1463a6
children 557eaa0339bf
line wrap: on
line diff
--- a/src/glyphs-x.c	Mon Aug 13 10:10:55 2007 +0200
+++ b/src/glyphs-x.c	Mon Aug 13 10:11:40 2007 +0200
@@ -57,9 +57,7 @@
 #include "sysfile.h"
 
 #ifdef HAVE_IMAGEMAGICK
-#ifdef SOLARIS2 /* Try to trick magick.h into not including Xos.h */
 #define _XOS_H_
-#endif
 #ifdef MAGICK_HEADERS_ARE_UNDER_X11
 #include <X11/magick/magick.h>
 #else
@@ -1756,7 +1754,7 @@
   Colormap cmap;
   Dimension depth;
   struct imagick_unwind_data unwind;
-  int speccount = specpdl_depth ();
+  int speccount;
   ImageInfo image_info;
 
   /* ImageMagick variables */
@@ -1775,6 +1773,7 @@
   memset (&unwind, 0, sizeof (unwind));
   unwind.dpy = dpy;
   unwind.cmap = cmap;
+  speccount = specpdl_depth();
   record_unwind_protect(imagick_instantiate_unwind,make_opaque_ptr(&unwind));
 
   /* Write out to a temp file - not sure if ImageMagick supports the
@@ -1882,7 +1881,7 @@
     int i,j,x,b;
     unsigned int bytes_per_pixel, scanline_pad;
     unsigned long pixval;
-    unsigned char *q;
+    unsigned char *q, pixar[3];
     RunlengthPacket *p;
 
     q = (unsigned char *) unwind.ximage->data;
@@ -1902,10 +1901,18 @@
 	  /* ### NOW what? */
 	  pixval = 0;
 	}
-	
+
+      for (b=0; b < bytes_per_pixel; b++) {
+	if (unwind.ximage->bitmap_bit_order == LSBFirst) 
+	  pixar[b] = (unsigned char)pixval;
+	else
+	  pixar[bytes_per_pixel - 1 - b] = (unsigned char)pixval;
+	pixval>>=8;
+      }
+
       for (j=0; j <= ((int) p->length); j++) {
 	for (b=0; b < bytes_per_pixel; b++) 
-	  *q++=(unsigned char) (pixval >> (8*b));
+	  *q++= pixar[b];
 	x++;
 	if (x == unwind.ximage->width) {
 	  x=0;