Browse Source

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 65e9712bdd)
tags/xfce4-panel-4.10.1
Andrzej Nick Schermer 8 years ago
parent
commit
ef184915ee
1 changed files with 5 additions and 7 deletions
  1. +5
    -7
      libxfce4panel/xfce-panel-convenience.c

+ 5
- 7
libxfce4panel/xfce-panel-convenience.c View File

@@ -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),


Loading…
Cancel
Save