aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Toshok <toshok@ximian.com>2004-02-28 09:22:47 +0800
committerChris Toshok <toshok@src.gnome.org>2004-02-28 09:22:47 +0800
commitf4afe8428691a13bd2d3de58a363317dc8f4a132 (patch)
tree43bba05f39fc378d1179f7be1ebe806b6dd6e644
parent377848c2969dd7d0595cc27c127cc31bd8e46925 (diff)
downloadgsoc2013-evolution-f4afe8428691a13bd2d3de58a363317dc8f4a132.tar.gz
gsoc2013-evolution-f4afe8428691a13bd2d3de58a363317dc8f4a132.tar.zst
gsoc2013-evolution-f4afe8428691a13bd2d3de58a363317dc8f4a132.zip
ref the pixbuf before we close/unref the loader so the pixbuf sticks
2004-02-27 Chris Toshok <toshok@ximian.com> * gui/widgets/eab-contact-display.c (eab_contact_display_render_compact): ref the pixbuf before we close/unref the loader so the pixbuf sticks around, and make the scaling logic a bit more transparent. svn path=/trunk/; revision=24916
-rw-r--r--addressbook/ChangeLog7
-rw-r--r--addressbook/gui/widgets/eab-contact-display.c20
2 files changed, 20 insertions, 7 deletions
diff --git a/addressbook/ChangeLog b/addressbook/ChangeLog
index cdea1bd2eb..63bd5b79e8 100644
--- a/addressbook/ChangeLog
+++ b/addressbook/ChangeLog
@@ -1,3 +1,10 @@
+2004-02-27 Chris Toshok <toshok@ximian.com>
+
+ * gui/widgets/eab-contact-display.c
+ (eab_contact_display_render_compact): ref the pixbuf before we
+ close/unref the loader so the pixbuf sticks around, and make the
+ scaling logic a bit more transparent.
+
2004-02-27 Rodney Dawes <dobey@ximian.com>
* gui/contact-editor/contact-editor.glade: Change the button relief
diff --git a/addressbook/gui/widgets/eab-contact-display.c b/addressbook/gui/widgets/eab-contact-display.c
index c1ceb7c335..87c8502147 100644
--- a/addressbook/gui/widgets/eab-contact-display.c
+++ b/addressbook/gui/widgets/eab-contact-display.c
@@ -370,18 +370,24 @@ eab_contact_display_render_compact (EABContactDisplay *display, EContact *contac
the html */
gdk_pixbuf_loader_write (loader, photo->data, photo->length, NULL);
pixbuf = gdk_pixbuf_loader_get_pixbuf (loader);
+ if (pixbuf)
+ gdk_pixbuf_ref (pixbuf);
gdk_pixbuf_loader_close (loader, NULL);
g_object_unref (loader);
if (pixbuf) {
- int max_dimension = gdk_pixbuf_get_height (pixbuf);
- if (max_dimension < gdk_pixbuf_get_width (pixbuf))
- max_dimension = gdk_pixbuf_get_width (pixbuf);
+ int max_dimension;
- calced_width = (float)gdk_pixbuf_get_width (pixbuf) / max_dimension * MAX_COMPACT_IMAGE_DIMENSION;
- calced_height = (float)gdk_pixbuf_get_height (pixbuf) / max_dimension * MAX_COMPACT_IMAGE_DIMENSION;
+ calced_width = gdk_pixbuf_get_width (pixbuf);
+ calced_height = gdk_pixbuf_get_height (pixbuf);
- calced_width = MIN (calced_width, MAX_COMPACT_IMAGE_DIMENSION);
- calced_height = MIN (calced_height, MAX_COMPACT_IMAGE_DIMENSION);
+ max_dimension = calced_width;
+ if (max_dimension < calced_height)
+ max_dimension = calced_height;
+
+ if (max_dimension > MAX_COMPACT_IMAGE_DIMENSION) {
+ calced_width *= ((float)MAX_COMPACT_IMAGE_DIMENSION / max_dimension);
+ calced_height *= ((float)MAX_COMPACT_IMAGE_DIMENSION / max_dimension);
+ }
}
gdk_pixbuf_unref (pixbuf);