]> Dogcows Code - chaz/openbox/commitdiff
fix 1bit bitmaps on msbfirst architectures + some indentation fixes
authorMikael Magnusson <mikachu@comhem.se>
Tue, 14 Mar 2006 15:27:15 +0000 (15:27 +0000)
committerMikael Magnusson <mikachu@comhem.se>
Tue, 14 Mar 2006 15:27:15 +0000 (15:27 +0000)
render/color.c
render/render.c

index 9f053e978bf985902d66059ccf5cc4eb3a17381b..c53a366e9eb30cfb1de481ff64bf0db4b24f460e 100644 (file)
@@ -154,7 +154,7 @@ void RrReduceDepth(const RrInstance *inst, RrPixel32 *data, XImage *im)
             data += im->width;
             p16 += im->bytes_per_line/2;
         }
-    break;
+        break;
     case 8:
         g_assert(RrVisual(inst)->class != TrueColor);
         for (y = 0; y < im->height; y++) {
@@ -163,12 +163,11 @@ void RrReduceDepth(const RrInstance *inst, RrPixel32 *data, XImage *im)
                                     data[x] >> RrDefaultRedOffset,
                                     data[x] >> RrDefaultGreenOffset,
                                     data[x] >> RrDefaultBlueOffset)->pixel;
+            }
+            data += im->width;
+            p8 += im->bytes_per_line;
         }
-        data += im->width;
-        p8 += im->bytes_per_line;
-  }
-
-    break;
+        break;
     default:
         g_warning("your bit depth is currently unhandled\n");
     }
@@ -204,9 +203,10 @@ static void swap_byte_order(XImage *im)
                 c[0] = c[1];
                 c[1] = t;
             case 8:
+            case 1:
                 break;
             default:
-                g_warning("your bit depth is currently unhandled");
+                g_warning("Your bit depth is currently unhandled");
             }
         }
         di += im->bytes_per_line;
index a41614051dc3c5e0974645927d32e87a84f99c0a..36d26a6f0f1670a24bd140f5b8a84fe557606772 100644 (file)
@@ -352,6 +352,14 @@ void RrMinsize(RrAppearance *a, gint *w, gint *h)
     if (*h < 1) *h = 1;
 }
 
+void reverse_bits(gchar *c, gint n)
+{
+    gint i;
+    for (i = 0; i < n; i++)
+        *c++ = (((*c * 0x0802UL & 0x22110UL) |
+                 (*c * 0x8020UL & 0x88440UL)) * 0x10101UL) >> 16;
+}
+
 gboolean RrPixmapToRGBA(const RrInstance *inst,
                         Pixmap pmap, Pixmap mask,
                         gint *w, gint *h, RrPixel32 **data)
@@ -361,9 +369,10 @@ gboolean RrPixmapToRGBA(const RrInstance *inst,
     guint pw, ph, mw, mh, xb, xd, i, x, y, di;
     XImage *xi, *xm = NULL;
 
-    if (!XGetGeometry(RrDisplay(inst),
-                      pmap, &xr, &xx, &xy, &pw, &ph, &xb, &xd))
+    if (!XGetGeometry(RrDisplay(inst), pmap,
+                      &xr, &xx, &xy, &pw, &ph, &xb, &xd))
         return FALSE;
+
     if (mask) {
         if (!XGetGeometry(RrDisplay(inst), mask,
                           &xr, &xx, &xy, &mw, &mh, &xb, &xd))
@@ -384,8 +393,13 @@ gboolean RrPixmapToRGBA(const RrInstance *inst,
             XDestroyImage(xi);
             return FALSE;
         }
+        if ((xm->bits_per_pixel == 1) && (xm->bitmap_bit_order != LSBFirst))
+            reverse_bits(xm->data, xm->bytes_per_line * xm->height);
     }
 
+    if ((xi->bits_per_pixel == 1) && (xi->bitmap_bit_order != LSBFirst))
+        reverse_bits(xi->data, xi->bytes_per_line * xi->height);
+
     *data = g_new(RrPixel32, pw * ph);
     RrIncreaseDepth(inst, *data, xi);
 
This page took 0.025973 seconds and 4 git commands to generate.