[frogr] Improved the way pictures are scaled



commit 9b81f5b7098c5ecdfc0c44f92f3356f8b4b624a9
Author: Mario Sanchez Prada <msanchez igalia com>
Date:   Tue Apr 10 22:59:03 2012 +0200

    Improved the way pictures are scaled

 src/frogr-util.c |   26 +++++++++++++++-----------
 1 files changed, 15 insertions(+), 11 deletions(-)
---
diff --git a/src/frogr-util.c b/src/frogr-util.c
index 77ea40a..bda7bf0 100644
--- a/src/frogr-util.c
+++ b/src/frogr-util.c
@@ -291,8 +291,6 @@ frogr_util_get_corrected_pixbuf (GdkPixbuf *pixbuf, gint max_width, gint max_hei
   const gchar *orientation;
   gint width;
   gint height;
-  gint new_width;
-  gint new_height;
 
   g_return_val_if_fail (max_width > 0, NULL);
   g_return_val_if_fail (max_height > 0, NULL);
@@ -300,21 +298,27 @@ frogr_util_get_corrected_pixbuf (GdkPixbuf *pixbuf, gint max_width, gint max_hei
   /* Look for the right side to reduce */
   width = gdk_pixbuf_get_width (pixbuf);
   height = gdk_pixbuf_get_height (pixbuf);
-  if (width > height)
+
+  DEBUG ("Original size: %dx%d\n", width, height);
+
+  if (width > max_width)
     {
-      new_width = max_width;
-      new_height = (float)new_width * height / width;
+      height = (float)height * max_width / width;
+      width = max_width;
     }
-  else
+
+  if (height > max_height)
     {
-      new_height = max_height;
-      new_width = (float)new_height * width / height;
+      width = (float)width * max_height / height;
+      height = max_height;
     }
 
+  DEBUG ("Scaled size: %dx%d\n", width, height);
+
   /* Scale the pixbuf to its best size */
-  scaled_pixbuf = gdk_pixbuf_scale_simple (pixbuf,
-                                           new_width, new_height,
-                                           GDK_INTERP_TILES);
+  scaled_pixbuf = gdk_pixbuf_scale_simple (pixbuf, width, height,
+                                           GDK_INTERP_BILINEAR);
+
   /* Correct orientation if needed */
   orientation = gdk_pixbuf_get_option (pixbuf, "orientation");
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]