pidgin: 82175cfc: Scale incoming thumbnails in the request...

malu at pidgin.im malu at pidgin.im
Mon May 3 16:25:38 EDT 2010


-----------------------------------------------------------------
Revision: 82175cfc320b7c831512ecc2a00beec2a86b7a2a
Ancestor: 2a50d625da688b225726bcb519f93d4ccece9ff2
Author: malu at pidgin.im
Date: 2010-05-03T20:23:17
Branch: im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/82175cfc320b7c831512ecc2a00beec2a86b7a2a

Modified files:
        libpurple/ft.c pidgin/gtkrequest.c

ChangeLog: 

Scale incoming thumbnails in the request dialog if they are overly large
WLM seems to send animations in some situations as a series of frames "encoded" in
a wide PNG...

-------------- next part --------------
============================================================
--- libpurple/ft.c	af208435bf53b32283e800dc856804e5f5e4fdee
+++ libpurple/ft.c	f67ecd8a7cc1b2507d7eb4480256a23fc0346ad0
@@ -521,7 +521,7 @@ purple_xfer_ask_recv(PurpleXfer *xfer)
 		if ((thumb = purple_xfer_get_thumbnail(xfer, &thumb_size))) {
 			purple_request_accept_cancel_with_icon(xfer, NULL, buf, NULL,
 				PURPLE_DEFAULT_ACTION_NONE, xfer->account, xfer->who, NULL,
-				thumb, thumb_size, xfer, 
+				thumb, thumb_size, xfer,
 				G_CALLBACK(purple_xfer_choose_file),
 				G_CALLBACK(cancel_recv_cb));
 		} else {
============================================================
--- pidgin/gtkrequest.c	1461a28f524985ce8c8793ee5689961fd67012b7
+++ pidgin/gtkrequest.c	a9887e1b5e4bb986ce308a7baac482eb4d207826
@@ -668,6 +668,23 @@ pidgin_request_action_with_icon(const ch
 		if (gdk_pixbuf_loader_write(loader, icon_data, icon_size, NULL)) {
 			pixbuf = gdk_pixbuf_loader_get_pixbuf(loader);
 			if (pixbuf) {
+				/* scale the image if it is too large */
+				int width = gdk_pixbuf_get_width(pixbuf);
+				int height = gdk_pixbuf_get_height(pixbuf);
+				if (width > 128 || height > 128) {
+					int scaled_width = width > height ? 128 : (128 * width) / height;
+					int scaled_height = height > width ? 128 : (128 * height) / width;
+					GdkPixbuf *scaled =
+							gdk_pixbuf_scale_simple(pixbuf, scaled_width, scaled_height,
+							    GDK_INTERP_BILINEAR);
+
+					purple_debug_info("pidgin",
+					    "dialog icon was too large, scale it down\n");
+					if (scaled) {
+						g_object_unref(pixbuf);
+						pixbuf = scaled;
+					}
+				}
 				img = gtk_image_new_from_pixbuf(pixbuf);
 			}
 		} else {


More information about the Commits mailing list