Stepan Salenikovich | 297b5d1 | 2015-02-26 17:51:13 -0500 | [diff] [blame] | 1 | /* |
Guillaume Roguez | 2a6150d | 2017-07-19 18:24:47 -0400 | [diff] [blame] | 2 | * Copyright (C) 2015-2017 Savoir-faire Linux Inc. |
Stepan Salenikovich | 297b5d1 | 2015-02-26 17:51:13 -0500 | [diff] [blame] | 3 | * Author: Stepan Salenikovich <stepan.salenikovich@savoirfairelinux.com> |
| 4 | * |
| 5 | * This program is free software; you can redistribute it and/or modify |
| 6 | * it under the terms of the GNU General Public License as published by |
| 7 | * the Free Software Foundation; either version 3 of the License, or |
| 8 | * (at your option) any later version. |
| 9 | * |
| 10 | * This program is distributed in the hope that it will be useful, |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | * GNU General Public License for more details. |
| 14 | * |
| 15 | * You should have received a copy of the GNU General Public License |
| 16 | * along with this program; if not, write to the Free Software |
| 17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
Stepan Salenikovich | 297b5d1 | 2015-02-26 17:51:13 -0500 | [diff] [blame] | 18 | */ |
| 19 | |
| 20 | #include "drawing.h" |
| 21 | |
| 22 | #include <gtk/gtk.h> |
| 23 | #include <math.h> |
AmarOk | b37e92b | 2017-07-19 09:40:00 -0400 | [diff] [blame] | 24 | #include <algorithm> |
Stepan Salenikovich | 297b5d1 | 2015-02-26 17:51:13 -0500 | [diff] [blame] | 25 | |
Stepan Salenikovich | d876507 | 2016-01-14 10:58:51 -0500 | [diff] [blame] | 26 | static constexpr const char* MSG_COUNT_FONT = "Sans"; |
| 27 | static constexpr int MSG_COUNT_FONT_SIZE = 12; |
| 28 | static constexpr GdkRGBA MSG_COUNT_FONT_COLOUR = {1.0, 1.0, 1.0, 1.0}; // white |
Nicolas Jager | d64d88e | 2017-12-11 14:26:00 -0500 | [diff] [blame^] | 29 | static constexpr GdkRGBA MSG_COUNT_BACKGROUND = {0.984, 0.282, 0.278, 1.0}; // red 251, 72, 71, 1.0 |
AmarOk | b37e92b | 2017-07-19 09:40:00 -0400 | [diff] [blame] | 30 | static constexpr GdkRGBA PRESENCE_PRESENT_BACKGROUND = {0, 0.4156827, 0.8, 1.0}; // green 112, 217, 6, 0.9 |
| 31 | static constexpr GdkRGBA PRESENCE_ABSENT_BACKGROUND = {0.984, 0.282, 0.278, 1.0}; // red 251, 72, 71, 0.9 |
Sébastien Blin | 9684dd3 | 2017-07-24 11:15:19 -0400 | [diff] [blame] | 32 | // This is the color palette for default avatars |
| 33 | static constexpr GdkRGBA COLOR_PALETTE[] = {{0.956862, 0.262745, 0.211764, 1.0}, // red 244, green 67, blue 54, 1 (red) |
| 34 | {0.913725, 0.117647, 0.388235, 1.0}, // red 233, green 30, blue 99, 1 (pink) |
| 35 | {0.611764, 0.152941, 0.690196, 1.0}, // red 156, green 39, blue 176, 1 (purple) |
| 36 | {0.403921, 0.227450, 0.717648, 1.0}, // red 244, green 67, blue 54, 1 (deep purple) |
| 37 | {0.247058, 0.317647, 0.709803, 1.0}, // red 103, green 58, blue 183, 1 (indigo) |
| 38 | {0.129411, 0.588235, 0.952941, 1.0}, // red 63, green 81, blue 54, 1 (blue) |
| 39 | {0, 0.838254, 0.831372, 1.0}, // red 0, green 188, blue 212, 1 (cyan) |
| 40 | {0, 0.588235, 0.533333, 1.0}, // red 0, green 150, blue 136, 1 (teal) |
| 41 | {0.298039, 0.682745, 0.313725, 1.0}, // red 244, green 67, blue 54, 1 (green) |
| 42 | {0.545098, 0.764705, 0.290196, 1.0}, // red 138, green 194, blue 73, 1 (light green) |
| 43 | {0.619607, 0.619607, 0.619607, 1.0}, // red 157, green 157, blue 157, 1 (grey) |
| 44 | {0.803921, 0.862745, 0.223529, 1.0}, // red 204, green 219, blue 56, 1 (lime) |
| 45 | {1, 0.756862, 0.027450, 1.0}, // red 255, green 192, blue 6, 1 (amber) |
| 46 | {1, 0.341176, 0.133333, 1.0}, // red 255, green 86, blue 33, 1 (deep orange) |
| 47 | {0.474509, 0.333333, 0.282352, 1.0}, // red 120, green 84, blue 71, 1 (brown) |
| 48 | {0.376470, 0.490196, 0.545098, 1.0}};// red 95, green 124, blue 138, 1 (blue grey) |
Stepan Salenikovich | d876507 | 2016-01-14 10:58:51 -0500 | [diff] [blame] | 49 | |
Stepan Salenikovich | 297b5d1 | 2015-02-26 17:51:13 -0500 | [diff] [blame] | 50 | GdkPixbuf * |
Sébastien Blin | 9684dd3 | 2017-07-24 11:15:19 -0400 | [diff] [blame] | 51 | ring_draw_fallback_avatar(int size, const char letter, const char color) { |
Stepan Salenikovich | 297b5d1 | 2015-02-26 17:51:13 -0500 | [diff] [blame] | 52 | cairo_surface_t *surface; |
| 53 | cairo_t *cr; |
| 54 | |
Sébastien Blin | 9684dd3 | 2017-07-24 11:15:19 -0400 | [diff] [blame] | 55 | // Fill the background |
Stepan Salenikovich | 297b5d1 | 2015-02-26 17:51:13 -0500 | [diff] [blame] | 56 | surface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, size, size); |
| 57 | cr = cairo_create(surface); |
Sébastien Blin | 9684dd3 | 2017-07-24 11:15:19 -0400 | [diff] [blame] | 58 | auto bg_color = COLOR_PALETTE[color % 16]; |
| 59 | cairo_set_source_rgb (cr, bg_color.red, bg_color.green, bg_color.blue); |
Stepan Salenikovich | 297b5d1 | 2015-02-26 17:51:13 -0500 | [diff] [blame] | 60 | cairo_paint(cr); |
| 61 | |
Sébastien Blin | 9684dd3 | 2017-07-24 11:15:19 -0400 | [diff] [blame] | 62 | // Draw a letter at the center of the avatar |
| 63 | cairo_text_extents_t extents; |
| 64 | cairo_select_font_face (cr, "monospace", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL); |
| 65 | cairo_set_font_size(cr, size / 2); |
| 66 | cairo_set_source_rgb (cr, 1, 1, 1); |
| 67 | char first_letter[2] = {0}; |
| 68 | first_letter[0] = letter; |
| 69 | cairo_text_extents (cr, first_letter, &extents); |
| 70 | auto x = size/2-(extents.width/2 + extents.x_bearing); |
| 71 | auto y = size/2-(extents.height/2 + extents.y_bearing); |
| 72 | cairo_move_to (cr, x, y); |
| 73 | cairo_show_text(cr, first_letter); |
Stepan Salenikovich | 2beca29 | 2015-08-17 17:03:21 -0400 | [diff] [blame] | 74 | |
Sébastien Blin | 9684dd3 | 2017-07-24 11:15:19 -0400 | [diff] [blame] | 75 | GdkPixbuf *pixbuf = gdk_pixbuf_get_from_surface(cairo_get_target(cr), 0, 0, size, size); |
Stepan Salenikovich | 297b5d1 | 2015-02-26 17:51:13 -0500 | [diff] [blame] | 76 | |
| 77 | /* free resources */ |
| 78 | cairo_destroy(cr); |
| 79 | cairo_surface_destroy(surface); |
| 80 | |
| 81 | return pixbuf; |
| 82 | } |
| 83 | |
| 84 | GdkPixbuf * |
Stepan Salenikovich | ee8506e | 2015-08-13 11:35:14 -0400 | [diff] [blame] | 85 | ring_draw_conference_avatar(int size) { |
| 86 | cairo_surface_t *surface; |
| 87 | cairo_t *cr; |
| 88 | |
| 89 | surface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, size, size); |
| 90 | cr = cairo_create(surface); |
| 91 | |
| 92 | cairo_pattern_t *linpat = cairo_pattern_create_linear(0, 0, 0, size); |
| 93 | cairo_pattern_add_color_stop_rgb(linpat, 0, 0.937, 0.937, 0.937); |
| 94 | cairo_pattern_add_color_stop_rgb(linpat, 1, 0.969, 0.969, 0.969); |
| 95 | |
| 96 | cairo_set_source(cr, linpat); |
| 97 | cairo_paint(cr); |
| 98 | |
| 99 | int avatar_size = size * 0.5; |
| 100 | GtkIconInfo *icon_info = gtk_icon_theme_lookup_icon(gtk_icon_theme_get_default(), "system-users-symbolic", |
| 101 | avatar_size, GTK_ICON_LOOKUP_GENERIC_FALLBACK); |
| 102 | GdkPixbuf *pixbuf_icon = gtk_icon_info_load_icon(icon_info, NULL); |
| 103 | g_object_unref(icon_info); |
| 104 | |
| 105 | if (pixbuf_icon != NULL) { |
| 106 | gdk_cairo_set_source_pixbuf(cr, pixbuf_icon, (size - avatar_size) / 2, (size - avatar_size) / 2); |
| 107 | g_object_unref(pixbuf_icon); |
| 108 | cairo_rectangle(cr, (size - avatar_size) / 2, (size - avatar_size) / 2, avatar_size, avatar_size); |
| 109 | cairo_fill(cr); |
| 110 | } |
| 111 | |
| 112 | GdkPixbuf *pixbuf = gdk_pixbuf_get_from_surface(surface, 0, 0, size, size); |
| 113 | |
| 114 | /* free resources */ |
| 115 | cairo_destroy(cr); |
| 116 | cairo_surface_destroy(surface); |
| 117 | |
| 118 | return pixbuf; |
| 119 | } |
| 120 | |
Sébastien Blin | 3367b66 | 2017-07-24 11:15:19 -0400 | [diff] [blame] | 121 | #include <iostream> |
AmarOk | b37e92b | 2017-07-19 09:40:00 -0400 | [diff] [blame] | 122 | |
Stepan Salenikovich | ee8506e | 2015-08-13 11:35:14 -0400 | [diff] [blame] | 123 | GdkPixbuf * |
Stepan Salenikovich | 297b5d1 | 2015-02-26 17:51:13 -0500 | [diff] [blame] | 124 | ring_frame_avatar(GdkPixbuf *avatar) { |
AmarOk | b37e92b | 2017-07-19 09:40:00 -0400 | [diff] [blame] | 125 | |
| 126 | auto w = gdk_pixbuf_get_width(avatar); |
| 127 | auto h = gdk_pixbuf_get_height(avatar); |
Sébastien Blin | 3367b66 | 2017-07-24 11:15:19 -0400 | [diff] [blame] | 128 | auto crop_size = std::min(h, w); |
| 129 | auto new_size = std::max(h, w); |
| 130 | auto scale = (double)new_size/(double)crop_size; |
| 131 | GdkPixbuf *crop_avatar = gdk_pixbuf_new ( |
| 132 | gdk_pixbuf_get_colorspace (avatar), |
| 133 | gdk_pixbuf_get_has_alpha (avatar), |
| 134 | gdk_pixbuf_get_bits_per_sample (avatar), |
| 135 | new_size, new_size); |
AmarOk | b37e92b | 2017-07-19 09:40:00 -0400 | [diff] [blame] | 136 | gdk_pixbuf_scale (avatar, crop_avatar, 0, 0, new_size, new_size, |
Sébastien Blin | 3367b66 | 2017-07-24 11:15:19 -0400 | [diff] [blame] | 137 | (w/2)-(new_size/2), (h/2)-(new_size/2), scale, scale, |
AmarOk | b37e92b | 2017-07-19 09:40:00 -0400 | [diff] [blame] | 138 | GDK_INTERP_BILINEAR); |
| 139 | auto extra_space = 10; |
| 140 | auto offset = extra_space/2; |
| 141 | auto s_surface = new_size + extra_space; |
| 142 | cairo_surface_t *surface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, s_surface, s_surface); |
Stepan Salenikovich | 297b5d1 | 2015-02-26 17:51:13 -0500 | [diff] [blame] | 143 | cairo_t *cr = cairo_create(surface); |
| 144 | |
| 145 | cairo_set_source_rgba(cr, 0, 0, 0, 0); |
AmarOk | b37e92b | 2017-07-19 09:40:00 -0400 | [diff] [blame] | 146 | cairo_rectangle(cr, 0, 0, s_surface, s_surface); |
Stepan Salenikovich | 297b5d1 | 2015-02-26 17:51:13 -0500 | [diff] [blame] | 147 | cairo_fill(cr); |
| 148 | |
AmarOk | b37e92b | 2017-07-19 09:40:00 -0400 | [diff] [blame] | 149 | double radius = new_size/2; |
Stepan Salenikovich | 297b5d1 | 2015-02-26 17:51:13 -0500 | [diff] [blame] | 150 | double degrees = M_PI / 180.0; |
| 151 | |
Stepan Salenikovich | 89e3d9f | 2016-06-06 11:57:31 -0400 | [diff] [blame] | 152 | // create the square path with ronded corners |
Stepan Salenikovich | 297b5d1 | 2015-02-26 17:51:13 -0500 | [diff] [blame] | 153 | cairo_new_sub_path (cr); |
AmarOk | b37e92b | 2017-07-19 09:40:00 -0400 | [diff] [blame] | 154 | cairo_arc (cr, offset + new_size - radius, offset + radius, radius, -90 * degrees, 0 * degrees); |
| 155 | cairo_arc (cr, offset + new_size - radius, offset + new_size - radius, radius, 0 * degrees, 90 * degrees); |
| 156 | cairo_arc (cr, offset + radius, offset + new_size - radius, radius, 90 * degrees, 180 * degrees); |
Stepan Salenikovich | 297b5d1 | 2015-02-26 17:51:13 -0500 | [diff] [blame] | 157 | cairo_arc (cr, offset + radius, offset + radius, radius, 180 * degrees, 270 * degrees); |
| 158 | cairo_close_path (cr); |
| 159 | |
Stepan Salenikovich | 89e3d9f | 2016-06-06 11:57:31 -0400 | [diff] [blame] | 160 | // in case the image has alpha, we want to first set the background of the part inside the |
Stepan Salenikovich | 1dc123f | 2016-09-14 10:43:10 -0400 | [diff] [blame] | 161 | // blue frame to white; otherwise the resulting image will show whatever is in the background, |
Stepan Salenikovich | 89e3d9f | 2016-06-06 11:57:31 -0400 | [diff] [blame] | 162 | // which can be weird in certain cases (eg: the image displayed over a video) |
Stepan Salenikovich | 1dc123f | 2016-09-14 10:43:10 -0400 | [diff] [blame] | 163 | cairo_set_source_rgba(cr, 1, 1, 1, 1); |
Stepan Salenikovich | 297b5d1 | 2015-02-26 17:51:13 -0500 | [diff] [blame] | 164 | cairo_fill_preserve(cr); |
| 165 | |
Stepan Salenikovich | 89e3d9f | 2016-06-06 11:57:31 -0400 | [diff] [blame] | 166 | // now draw the image over this black square |
AmarOk | b37e92b | 2017-07-19 09:40:00 -0400 | [diff] [blame] | 167 | gdk_cairo_set_source_pixbuf(cr, crop_avatar, offset, offset); |
Stepan Salenikovich | 89e3d9f | 2016-06-06 11:57:31 -0400 | [diff] [blame] | 168 | cairo_fill_preserve(cr); |
| 169 | |
AmarOk | b37e92b | 2017-07-19 09:40:00 -0400 | [diff] [blame] | 170 | auto pixbuf = gdk_pixbuf_get_from_surface(surface, 0, 0, s_surface, s_surface); |
Stepan Salenikovich | 297b5d1 | 2015-02-26 17:51:13 -0500 | [diff] [blame] | 171 | |
| 172 | /* free resources */ |
| 173 | cairo_destroy(cr); |
| 174 | cairo_surface_destroy(surface); |
| 175 | |
| 176 | return pixbuf; |
Stepan Salenikovich | 2beca29 | 2015-08-17 17:03:21 -0400 | [diff] [blame] | 177 | } |
Stepan Salenikovich | d876507 | 2016-01-14 10:58:51 -0500 | [diff] [blame] | 178 | |
| 179 | static void |
| 180 | create_rounded_rectangle_path(cairo_t *cr, double corner_radius, double x, double y, double w, double h) |
| 181 | { |
| 182 | double radius = corner_radius; |
| 183 | double degrees = M_PI / 180.0; |
| 184 | |
| 185 | cairo_new_sub_path (cr); |
| 186 | cairo_arc (cr, x + w - radius, y + radius, radius, -90 * degrees, 0 * degrees); |
| 187 | cairo_arc (cr, x + w - radius, y + h - radius, radius, 0 * degrees, 90 * degrees); |
| 188 | cairo_arc (cr, x + radius, y + h - radius, radius, 90 * degrees, 180 * degrees); |
| 189 | cairo_arc (cr, x + radius, y + radius, radius, 180 * degrees, 270 * degrees); |
| 190 | cairo_close_path (cr); |
| 191 | } |
| 192 | |
| 193 | /** |
aviau | c372e81 | 2016-12-01 16:13:16 -0500 | [diff] [blame] | 194 | * Draws the presence icon in the top right corner of the given image. |
| 195 | */ |
| 196 | GdkPixbuf * |
| 197 | ring_draw_presence(const GdkPixbuf *avatar, bool present) { |
| 198 | if (!present) { |
| 199 | // simply return a copy of the original pixbuf |
| 200 | return gdk_pixbuf_copy(avatar); |
| 201 | } |
| 202 | |
| 203 | int w = gdk_pixbuf_get_width(avatar); |
| 204 | int h = gdk_pixbuf_get_height(avatar); |
| 205 | cairo_surface_t *surface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, w, h); |
| 206 | cairo_t *cr = cairo_create(surface); |
| 207 | cairo_surface_destroy(surface); |
| 208 | |
| 209 | /* draw original image */ |
| 210 | gdk_cairo_set_source_pixbuf(cr, avatar, 0, 0); |
| 211 | cairo_paint(cr); |
| 212 | |
| 213 | /* draw rounded rectangle, with 3 pixel border |
| 214 | * ie: 6 pixels higher, 6 pixels wider */ |
| 215 | int border_width = 5; |
AmarOk | b37e92b | 2017-07-19 09:40:00 -0400 | [diff] [blame] | 216 | double rec_x = w - border_width * 3; |
| 217 | double rec_y = h - border_width * 3; |
aviau | c372e81 | 2016-12-01 16:13:16 -0500 | [diff] [blame] | 218 | double rec_w = border_width * 2; |
| 219 | double rec_h = border_width * 2; |
| 220 | double corner_radius = rec_h/2.5; |
| 221 | create_rounded_rectangle_path(cr, corner_radius, rec_x, rec_y, rec_w, rec_h); |
| 222 | |
| 223 | // For now we don't draw the absent background. |
| 224 | auto background = present ? PRESENCE_PRESENT_BACKGROUND : PRESENCE_ABSENT_BACKGROUND; |
| 225 | cairo_set_source_rgba( |
| 226 | cr, |
| 227 | background.red, |
| 228 | background.blue, |
| 229 | background.green, |
| 230 | background.alpha |
| 231 | ); |
AmarOk | b37e92b | 2017-07-19 09:40:00 -0400 | [diff] [blame] | 232 | cairo_fill_preserve(cr); |
| 233 | cairo_set_source_rgb(cr, 1, 1, 1); |
| 234 | cairo_set_line_width(cr, 1.2); |
| 235 | cairo_stroke(cr); |
aviau | c372e81 | 2016-12-01 16:13:16 -0500 | [diff] [blame] | 236 | |
| 237 | GdkPixbuf *pixbuf = gdk_pixbuf_get_from_surface(surface, 0, 0, w, h); |
| 238 | |
| 239 | /* free resources */ |
| 240 | cairo_destroy(cr); |
| 241 | |
| 242 | return pixbuf; |
| 243 | } |
| 244 | |
| 245 | /** |
Stepan Salenikovich | d876507 | 2016-01-14 10:58:51 -0500 | [diff] [blame] | 246 | * Draws the unread message count in the bottom right corner of the given image. |
| 247 | * In the case that the count is less than or equal to 0, nothing is drawn. |
| 248 | */ |
| 249 | GdkPixbuf * |
| 250 | ring_draw_unread_messages(const GdkPixbuf *avatar, int unread_count) { |
| 251 | if (unread_count <= 0) { |
| 252 | // simply return a copy of the original pixbuf |
| 253 | return gdk_pixbuf_copy(avatar); |
| 254 | } |
| 255 | int w = gdk_pixbuf_get_width(avatar); |
| 256 | int h = gdk_pixbuf_get_height(avatar); |
| 257 | cairo_surface_t *surface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, w, h); |
| 258 | cairo_t *cr = cairo_create(surface); |
| 259 | cairo_surface_destroy(surface); |
| 260 | |
| 261 | /* draw original image */ |
| 262 | gdk_cairo_set_source_pixbuf(cr, avatar, 0, 0); |
| 263 | cairo_paint(cr); |
| 264 | |
| 265 | /* make text */ |
Nicolas Jager | d64d88e | 2017-12-11 14:26:00 -0500 | [diff] [blame^] | 266 | char *text = g_strdup_printf("%s", unread_count > 9 ? "9+" : std::to_string(unread_count).c_str()); |
Stepan Salenikovich | d876507 | 2016-01-14 10:58:51 -0500 | [diff] [blame] | 267 | cairo_text_extents_t extents; |
| 268 | |
| 269 | cairo_select_font_face (cr, MSG_COUNT_FONT, |
| 270 | CAIRO_FONT_SLANT_NORMAL, |
| 271 | CAIRO_FONT_WEIGHT_NORMAL); |
| 272 | |
| 273 | cairo_set_font_size (cr, MSG_COUNT_FONT_SIZE); |
| 274 | cairo_text_extents (cr, text, &extents); |
| 275 | |
| 276 | /* draw rounded rectangle around the text, with 3 pixel border |
| 277 | * ie: 6 pixels higher, 6 pixels wider */ |
| 278 | int border_width = 3; |
| 279 | double rec_x = w - extents.width - border_width * 2; |
Nicolas Jager | d64d88e | 2017-12-11 14:26:00 -0500 | [diff] [blame^] | 280 | double rec_y = 0; |
Stepan Salenikovich | d876507 | 2016-01-14 10:58:51 -0500 | [diff] [blame] | 281 | double rec_w = extents.width + border_width * 2; |
| 282 | double rec_h = extents.height + border_width * 2; |
| 283 | double corner_radius = rec_h/2.5; |
| 284 | create_rounded_rectangle_path(cr, corner_radius, rec_x, rec_y, rec_w, rec_h); |
Nicolas Jager | d64d88e | 2017-12-11 14:26:00 -0500 | [diff] [blame^] | 285 | cairo_set_source_rgba(cr, |
| 286 | MSG_COUNT_BACKGROUND.red, |
| 287 | MSG_COUNT_BACKGROUND.blue, MSG_COUNT_BACKGROUND.green, MSG_COUNT_BACKGROUND.alpha); |
Stepan Salenikovich | d876507 | 2016-01-14 10:58:51 -0500 | [diff] [blame] | 288 | cairo_fill(cr); |
| 289 | |
| 290 | /* draw text */ |
Nicolas Jager | d64d88e | 2017-12-11 14:26:00 -0500 | [diff] [blame^] | 291 | cairo_move_to (cr, w - extents.width-border_width, extents.height + border_width ); |
Stepan Salenikovich | d876507 | 2016-01-14 10:58:51 -0500 | [diff] [blame] | 292 | cairo_set_source_rgb(cr, MSG_COUNT_FONT_COLOUR.red, MSG_COUNT_FONT_COLOUR.blue, MSG_COUNT_FONT_COLOUR.green); |
| 293 | cairo_show_text (cr, text); |
| 294 | |
| 295 | GdkPixbuf *pixbuf = gdk_pixbuf_get_from_surface(surface, 0, 0, w, h); |
| 296 | |
| 297 | /* free resources */ |
| 298 | cairo_destroy(cr); |
| 299 | g_free(text); |
| 300 | |
| 301 | return pixbuf; |
| 302 | } |