]> Dogcows Code - chaz/openbox/blobdiff - render/render.c
try another scaling algo for the icons
[chaz/openbox] / render / render.c
index 3fb4965b9d1c68c4c759e4a69b3c65045db30faf..05f7c9931c11a9837ff26787ae0d24628f72902a 100644 (file)
@@ -39,7 +39,7 @@ static void pixel_data_to_pixmap(RrAppearance *l,
 
 void RrPaint(RrAppearance *a, Window win, gint w, gint h)
 {
-    int i, transferred = 0, sw;
+    gint i, transferred = 0, sw;
     RrPixel32 *source, *dest;
     Pixmap oldp;
     RrRect tarea; /* area in which to draw textures */
@@ -278,7 +278,7 @@ static void pixel_data_to_pixmap(RrAppearance *l,
    as reduce_depth just sets im->data = data and returns
 */
     scratch = g_new(RrPixel32, im->width * im->height);
-    im->data = (char*) scratch;
+    im->data = (gchar*) scratch;
     RrReduceDepth(l->inst, in, im);
     XPutImage(RrDisplay(l->inst), out,
               DefaultGC(RrDisplay(l->inst), RrScreen(l->inst)),
@@ -311,7 +311,7 @@ void RrMargins (RrAppearance *a, gint *l, gint *t, gint *r, gint *b)
 void RrMinsize(RrAppearance *a, gint *w, gint *h)
 {
     gint i;
-    gint m;
+    RrSize *m;
     gint l, t, r, b;
     *w = *h = 0;
 
@@ -326,9 +326,9 @@ void RrMinsize(RrAppearance *a, gint *w, gint *h)
         case RR_TEXTURE_TEXT:
             m = RrFontMeasureString(a->texture[i].data.text.font,
                                     a->texture[i].data.text.string);
-            *w = MAX(*w, m);
-            m = RrFontHeight(a->texture[i].data.text.font);
-            *h += MAX(*h, m);
+            *w = MAX(*w, m->width + 4);
+            m->height = RrFontHeight(a->texture[i].data.text.font);
+            *h += MAX(*h, m->height);
             break;
         case RR_TEXTURE_RGBA:
             *w += MAX(*w, a->texture[i].data.rgba.width);
@@ -352,6 +352,14 @@ void RrMinsize(RrAppearance *a, gint *w, gint *h)
     if (*h < 1) *h = 1;
 }
 
+static 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.024119 seconds and 4 git commands to generate.