From dcdf9eb677e315e88623182879a589787408a5ff Mon Sep 17 00:00:00 2001 From: Patrick McDermott Date: Fri, 03 Nov 2017 14:25:12 -0400 Subject: mq_profile_icon_new_pixbuf(): New function --- (limited to 'src') 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 +#include #include +#include #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 #include 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 */ -- cgit v0.9.1