From 34dbe117b0ca67b5c1e80e11b529e9863c9c9758 Mon Sep 17 00:00:00 2001 From: Colomban Wendling Date: Tue, 24 Jan 2017 15:28:40 +0100 Subject: status-notifier: Fix item icons transparency --- .../notification_area/status-notifier/sn-item-v0.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/applets/notification_area/status-notifier/sn-item-v0.c b/applets/notification_area/status-notifier/sn-item-v0.c index 0ef0570a..0ab07ce4 100644 --- a/applets/notification_area/status-notifier/sn-item-v0.c +++ b/applets/notification_area/status-notifier/sn-item-v0.c @@ -344,6 +344,9 @@ surface_from_variant (GVariant *variant, cairo_format_t format; gint stride; guint32 *data; + gint x; + gint y; + guchar *p; format = CAIRO_FORMAT_ARGB32; stride = cairo_format_stride_for_width (format, width); @@ -358,6 +361,22 @@ surface_from_variant (GVariant *variant, } #endif + p = (guchar *) data; + /* premultiply alpha for Cairo */ + for (y = 0; y < height; y++) + { + for (x = 0; x < width; x++) + { + guchar alpha = p[x * 4 + 3]; + + p[x * 4 + 0] = (p[x * 4 + 0] * alpha) / 255; + p[x * 4 + 1] = (p[x * 4 + 1] * alpha) / 255; + p[x * 4 + 2] = (p[x * 4 + 2] * alpha) / 255; + } + + p += stride; + } + return cairo_image_surface_create_for_data ((guchar *) data, format, width, height, stride); } -- cgit v1.2.1