From d12208b30fe99cd3ed1d6c4a5b8cddb9ad36653a Mon Sep 17 00:00:00 2001 From: teuf Date: Sun, 6 Jul 2008 09:42:07 +0000 Subject: Fix bug in thumbnail resizing when not cropping which caused duplicated lines at the bottom of thumbnails git-svn-id: https://gtkpod.svn.sf.net/svnroot/gtkpod/libgpod/trunk@2036 f01d2545-417e-4e96-918e-98f8d0dbbcb6 --- ChangeLog | 6 ++++++ src/ithumb-writer.c | 41 +++++++++++++++++++++-------------------- 2 files changed, 27 insertions(+), 20 deletions(-) diff --git a/ChangeLog b/ChangeLog index e3d10dc..fc7e6fe 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2008-07-06 Christophe Fergeau + + * src/ithumb-writer.c: fix bug in the function scaling and cropping + thumbnails, in the non-cropping case, the returned pixbuf size + didn't reflect the size of the scaled pixbuf + 2008-07-05 Christophe Fergeau * src/db-artwork-parser.c: fix small memory leak diff --git a/src/ithumb-writer.c b/src/ithumb-writer.c index 1f57b93..95d4a3d 100644 --- a/src/ithumb-writer.c +++ b/src/ithumb-writer.c @@ -772,9 +772,10 @@ ithumb_writer_scale_and_crop (GdkPixbuf *input_pixbuf, factors. */ scale = MIN(width_scale, height_scale); offset_x = offset_y = 0; - } - else - { + return gdk_pixbuf_scale_simple (input_pixbuf, + input_width*scale, input_height*scale, + GDK_INTERP_BILINEAR); + } else { double scaled_width, scaled_height; /* If we are cropping, we use the max of the two possible scale factors, so that the image is large enough to fill both dimensions. */ @@ -791,24 +792,24 @@ ithumb_writer_scale_and_crop (GdkPixbuf *input_pixbuf, offset_y = round((height - scaled_height) / 2); g_assert(round(scaled_width) == width || - round(scaled_height) == height); + round(scaled_height) == height); + + output_pixbuf = gdk_pixbuf_new(GDK_COLORSPACE_RGB, FALSE, 8, + width + border_width, + height + border_width); + gdk_pixbuf_fill(output_pixbuf, 0xffffffff); + + gdk_pixbuf_scale (input_pixbuf, + output_pixbuf, + 0, 0, /* dest x, dest y */ + width, /* dest width */ + height, /* dest height */ + offset_x, offset_y, /* offset x, offset y */ + scale, scale, /* scale x, scale y */ + GDK_INTERP_BILINEAR); + + return output_pixbuf; } - - output_pixbuf = gdk_pixbuf_new(GDK_COLORSPACE_RGB, FALSE, 8, - width + border_width, - height + border_width); - gdk_pixbuf_fill(output_pixbuf, 0xffffffff); - - gdk_pixbuf_scale (input_pixbuf, - output_pixbuf, - 0, 0, /* dest x, dest y */ - width, /* dest width */ - height, /* dest height */ - offset_x, offset_y, /* offset x, offset y */ - scale, scale, /* scale x, scale y */ - GDK_INTERP_BILINEAR); - - return output_pixbuf; } static GdkPixbuf * -- cgit