[libhandy] avatar: Center custom images
- From: Alexander Mikhaylenko <alexm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libhandy] avatar: Center custom images
- Date: Thu, 29 Oct 2020 11:46:24 +0000 (UTC)
commit 2dacd3e4c1a31c66ef3da3b09ad362cc91f7f439
Author: Alexander Mikhaylenko <alexm gnome org>
Date: Sat Oct 3 04:33:12 2020 +0500
avatar: Center custom images
Right now it picks top left corner, which isn't really expected for
avatars.
src/hdy-avatar.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
---
diff --git a/src/hdy-avatar.c b/src/hdy-avatar.c
index d330d73f..71b015f0 100644
--- a/src/hdy-avatar.c
+++ b/src/hdy-avatar.c
@@ -100,13 +100,15 @@ round_image (GdkPixbuf *pixbuf,
{
g_autoptr (cairo_surface_t) surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, size, size);
g_autoptr (cairo_t) cr = cairo_create (surface);
+ gint width = gdk_pixbuf_get_width (pixbuf);
+ gint height = gdk_pixbuf_get_height (pixbuf);
/* Clip a circle */
cairo_arc (cr, size / 2.0, size / 2.0, size / 2.0, 0, 2 * G_PI);
cairo_clip (cr);
cairo_new_path (cr);
- gdk_cairo_set_source_pixbuf (cr, pixbuf, 0, 0);
+ gdk_cairo_set_source_pixbuf (cr, pixbuf, (size - width) / 2, (size - height) / 2);
cairo_paint (cr);
return g_steal_pointer (&surface);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]