File qtcurve-gtk2-iconeffects.diff of Package qtcurve-gtk2

--- style/qtcurve.c.org	2008-10-19 13:05:01.000000000 +1100
+++ style/qtcurve.c	2008-10-19 13:06:13.000000000 +1100
@@ -5702,6 +5702,57 @@
     //QTC_CAIRO_END
 }
 
+// copypasta
+static GdkPixbuf * set_transparency (const GdkPixbuf *pixbuf, gdouble alpha_percent)
+{
+    GdkPixbuf *target;
+    guchar *data, *current;
+    guint x, y, rowstride, height, width;
+
+    g_return_val_if_fail (pixbuf != NULL, NULL);
+    g_return_val_if_fail (GDK_IS_PIXBUF (pixbuf), NULL);
+
+    /* Returns a copy of pixbuf with it's non-completely-transparent pixels to
+       have an alpha level "alpha_percent" of their original value. */
+
+    target = gdk_pixbuf_add_alpha (pixbuf, FALSE, 0, 0, 0);
+
+    if (alpha_percent == 1.0)
+        return target;
+    width = gdk_pixbuf_get_width (target);
+    height = gdk_pixbuf_get_height (target);
+    rowstride = gdk_pixbuf_get_rowstride (target);
+    data = gdk_pixbuf_get_pixels (target);
+
+    for (y = 0; y < height; y++)
+    {
+        for (x = 0; x < width; x++)
+        {
+            /* The "4" is the number of chars per pixel, in this case, RGBA,
+               the 3 means "skip to the alpha" */
+            current = data + (y * rowstride) + (x * 4) + 3;
+            *(current) = (guchar) (*(current) * alpha_percent);
+        }
+    }
+
+    return target;
+}
+
+static GdkPixbuf* scale_or_ref (GdkPixbuf *src, int width, int height)
+{
+    if (width == gdk_pixbuf_get_width (src) &&
+        height == gdk_pixbuf_get_height (src))
+    {
+        return g_object_ref (src);
+    }
+    else
+    {
+        return gdk_pixbuf_scale_simple (src,
+                                        width, height,
+                                        GDK_INTERP_BILINEAR);
+    }
+}
+
 static void styleRealize(GtkStyle *style)
 {
     QtCurveStyle *qtcurveStyle = (QtCurveStyle *)style;
openSUSE Build Service is sponsored by