[Xfce4-commits] <xfce4-panel:xfce-4.10> Bugfix in icon/pixbuf resizing code.

Nick Schermer noreply at xfce.org
Sun May 5 17:50:10 CEST 2013


Updating branch refs/heads/xfce-4.10
         to ef184915ee033dec4084f3d762c81c2b130a2629 (commit)
       from a51135ef6b529e53462ed4e06825f28dcbe1d5b2 (commit)

commit ef184915ee033dec4084f3d762c81c2b130a2629
Author: Andrzej <ndrwrdck at gmail.com>
Date:   Wed Apr 3 22:33:51 2013 +0100

    Bugfix in icon/pixbuf resizing code.
    
    Icons were occasionally stretched to unnatural aspect ratio.
    This could be observed e.g. in applications menu plugin in multi-row
    panels and/or non-square icons.
    
    (cherry picked from commit 65e9712bdd3f1f7013856ff8af0e311a57fa8d34)

 libxfce4panel/xfce-panel-convenience.c |   12 +++++-------
 1 files changed, 5 insertions(+), 7 deletions(-)

diff --git a/libxfce4panel/xfce-panel-convenience.c b/libxfce4panel/xfce-panel-convenience.c
index a3f3be1..7902360 100644
--- a/libxfce4panel/xfce-panel-convenience.c
+++ b/libxfce4panel/xfce-panel-convenience.c
@@ -158,7 +158,7 @@ xfce_panel_pixbuf_from_source_at_size (const gchar  *source,
   gchar     *name;
   gchar     *filename;
   gint       src_w, src_h;
-  gdouble    wratio, hratio;
+  gdouble    ratio;
   GdkPixbuf *dest;
   GError    *error = NULL;
   gint       size = MIN (dest_width, dest_height);
@@ -231,13 +231,11 @@ xfce_panel_pixbuf_from_source_at_size (const gchar  *source,
       if (src_w > dest_width || src_h > dest_height)
         {
           /* calculate the new dimensions */
-          wratio = (gdouble) src_w / (gdouble) size;
-          hratio = (gdouble) src_h / (gdouble) size;
+          ratio = MIN ((gdouble) dest_width / (gdouble) src_w,
+                       (gdouble) dest_height / (gdouble) src_h);
 
-          if (hratio > wratio)
-            dest_width  = rint (src_w / hratio);
-          else
-            dest_height = rint (src_h / wratio);
+          dest_width  = rint (src_w * ratio);
+          dest_height = rint (src_h * ratio);
 
           dest = gdk_pixbuf_scale_simple (pixbuf,
                                           MAX (dest_width, 1),


More information about the Xfce4-commits mailing list