summaryrefslogtreecommitdiffstats
path: root/src/utils
diff options
context:
space:
mode:
authorPatrick McDermott <pj@pehjota.net>2017-11-03 14:25:12 (EDT)
committer Patrick McDermott <pj@pehjota.net>2017-11-03 14:25:12 (EDT)
commitdcdf9eb677e315e88623182879a589787408a5ff (patch)
tree47d9aad814a61d0a8b59662c8b40168452174e08 /src/utils
parent443905edbb8457e7f53b435d3fd284d49f903532 (diff)
downloadmarquee-dcdf9eb677e315e88623182879a589787408a5ff.zip
marquee-dcdf9eb677e315e88623182879a589787408a5ff.tar.gz
marquee-dcdf9eb677e315e88623182879a589787408a5ff.tar.bz2
mq_profile_icon_new_pixbuf(): New function
Diffstat (limited to 'src/utils')
-rw-r--r--src/utils/profile-icon.c29
-rw-r--r--src/utils/profile-icon.h4
2 files changed, 33 insertions, 0 deletions
diff --git a/src/utils/profile-icon.c b/src/utils/profile-icon.c
index 20451fa..e4f8d4d 100644
--- a/src/utils/profile-icon.c
+++ b/src/utils/profile-icon.c
@@ -21,7 +21,10 @@
#include "profile-icon.h"
+#include <cairo.h>
+#include <gdk-pixbuf/gdk-pixbuf.h>
#include <glib.h>
+#include <librsvg/rsvg.h>
#include "svg.h"
@@ -44,3 +47,29 @@ mq_profile_icon_new(const gchar *color)
return mq_svg_set_color(profile_svg, color);
}
+
+GdkPixbuf *
+mq_profile_icon_new_pixbuf(const gchar *color)
+{
+ cairo_surface_t *surface;
+ cairo_t *cr;
+ gchar *data;
+ RsvgHandle *handle;
+ GdkPixbuf *pixbuf;
+
+ surface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, 16, 16);
+ cr = cairo_create(surface);
+
+ data = mq_profile_icon_new(color);
+ handle = rsvg_handle_new_from_data((guint8 *) data, strlen(data), NULL);
+ rsvg_handle_render_cairo(handle, cr);
+
+ pixbuf = gdk_pixbuf_get_from_surface(surface, 0, 0,
+ cairo_image_surface_get_width(surface),
+ cairo_image_surface_get_height(surface));
+
+ cairo_destroy(cr);
+ cairo_surface_destroy(surface);
+
+ return pixbuf;
+}
diff --git a/src/utils/profile-icon.h b/src/utils/profile-icon.h
index d4c8244..c8f7167 100644
--- a/src/utils/profile-icon.h
+++ b/src/utils/profile-icon.h
@@ -22,6 +22,7 @@
#ifndef MQ_UTILS_PROFILE_ICON_H
#define MQ_UTILS_PROFILE_ICON_H
+#include <gdk-pixbuf/gdk-pixbuf.h>
#include <glib.h>
G_BEGIN_DECLS
@@ -29,6 +30,9 @@ G_BEGIN_DECLS
gchar *
mq_profile_icon_new(const gchar *color);
+GdkPixbuf *
+mq_profile_icon_new_pixbuf(const gchar *color);
+
G_END_DECLS
#endif /* MQ_UTILS_PROFILE_ICON_H */