Mercurial > pidgin
comparison pidgin/gtkblist.c @ 22484:ed786719b10a
scale & round the buddy icon in the buddy list before making it square, so
rectangular (but non-square) images get rounded corners too. Fixes #2110
author | Stu Tomlinson <stu@nosnilmot.com> |
---|---|
date | Sun, 16 Mar 2008 18:55:07 +0000 |
parents | 57fef22fa7a8 |
children | f54a1f4f2963 |
comparison
equal
deleted
inserted
replaced
22483:7a815907ba5a | 22484:ed786719b10a |
---|---|
2496 | 2496 |
2497 if (prpl_info && prpl_info->icon_spec.scale_rules & PURPLE_ICON_SCALE_DISPLAY) | 2497 if (prpl_info && prpl_info->icon_spec.scale_rules & PURPLE_ICON_SCALE_DISPLAY) |
2498 purple_buddy_icon_get_scale_size(&prpl_info->icon_spec, &scale_width, &scale_height); | 2498 purple_buddy_icon_get_scale_size(&prpl_info->icon_spec, &scale_width, &scale_height); |
2499 | 2499 |
2500 if (scaled || scale_height > 200 || scale_width > 200) { | 2500 if (scaled || scale_height > 200 || scale_width > 200) { |
2501 GdkPixbuf *tmpbuf; | |
2501 float scale_size = scaled ? 32.0 : 200.0; | 2502 float scale_size = scaled ? 32.0 : 200.0; |
2502 if(scale_height > scale_width) { | 2503 if(scale_height > scale_width) { |
2503 scale_width = scale_size * (double)scale_width / (double)scale_height; | 2504 scale_width = scale_size * (double)scale_width / (double)scale_height; |
2504 scale_height = scale_size; | 2505 scale_height = scale_size; |
2505 } else { | 2506 } else { |
2506 scale_height = scale_size * (double)scale_height / (double)scale_width; | 2507 scale_height = scale_size * (double)scale_height / (double)scale_width; |
2507 scale_width = scale_size; | 2508 scale_width = scale_size; |
2508 } | 2509 } |
2509 | 2510 /* scale & round before making square, so rectangular (but non-square) |
2511 * images get rounded corners too */ | |
2512 tmpbuf = gdk_pixbuf_new(GDK_COLORSPACE_RGB, TRUE, 8, scale_width, scale_height); | |
2513 gdk_pixbuf_fill(tmpbuf, 0x00000000); | |
2514 gdk_pixbuf_scale(buf, tmpbuf, 0, 0, scale_width, scale_height, 0, 0, (double)scale_width/(double)orig_width, (double)scale_height/(double)orig_height, GDK_INTERP_BILINEAR); | |
2515 if (pidgin_gdk_pixbuf_is_opaque(tmpbuf)) | |
2516 pidgin_gdk_pixbuf_make_round(tmpbuf); | |
2510 ret = gdk_pixbuf_new(GDK_COLORSPACE_RGB, TRUE, 8, scale_size, scale_size); | 2517 ret = gdk_pixbuf_new(GDK_COLORSPACE_RGB, TRUE, 8, scale_size, scale_size); |
2511 gdk_pixbuf_fill(ret, 0x00000000); | 2518 gdk_pixbuf_fill(ret, 0x00000000); |
2512 gdk_pixbuf_scale(buf, ret, (scale_size-scale_width)/2, (scale_size-scale_height)/2, scale_width, scale_height, (scale_size-scale_width)/2, (scale_size-scale_height)/2, (double)scale_width/(double)orig_width, (double)scale_height/(double)orig_height, GDK_INTERP_BILINEAR); | 2519 gdk_pixbuf_copy_area(tmpbuf, 0, 0, scale_width, scale_height, ret, (scale_size-scale_width)/2, (scale_size-scale_height)/2); |
2513 if (pidgin_gdk_pixbuf_is_opaque(ret)) | 2520 g_object_unref(G_OBJECT(tmpbuf)); |
2514 pidgin_gdk_pixbuf_make_round(ret); | |
2515 } else { | 2521 } else { |
2516 ret = gdk_pixbuf_scale_simple(buf,scale_width,scale_height, GDK_INTERP_BILINEAR); | 2522 ret = gdk_pixbuf_scale_simple(buf,scale_width,scale_height, GDK_INTERP_BILINEAR); |
2517 } | 2523 } |
2518 g_object_unref(G_OBJECT(buf)); | 2524 g_object_unref(G_OBJECT(buf)); |
2519 } | 2525 } |