improve image display, particularly for large images, especially if taller than they...
authorPaul <paul@claws-mail.org>
Mon, 17 Aug 2020 09:47:25 +0000 (10:47 +0100)
committerPaul <paul@claws-mail.org>
Mon, 17 Aug 2020 09:47:25 +0000 (10:47 +0100)
src/gtk/gtkutils.c

index 4eea7fb31d61b844e8a865e3e6e7d1076cb39ba6..f09d5a84fd265456d37fa39b4102da88d29eaee2 100644 (file)
@@ -1750,32 +1750,6 @@ GdkPixbuf *claws_load_pixbuf_fitting(GdkPixbuf *src_pixbuf, int box_width,
                }
        }
 
-       w = gdk_pixbuf_get_width(pixbuf);
-       h = gdk_pixbuf_get_height(pixbuf);
-
-       if (angle == 90 || angle == 270) {
-               avail_height = box_width;
-               avail_width = box_height;
-       } else {
-               avail_width = box_width;
-               avail_height = box_height;
-       }
-
-       /* Scale first */
-       if (box_width != -1 && box_height != -1 && avail_width - 100 > 0) {
-               if (w > avail_width) {
-                       h = (avail_width * h) / w;
-                       w = avail_width;
-               }
-               if (h > avail_height) {
-                       w = (avail_height * w) / h;
-                       h = avail_height;
-               }
-               t_pixbuf = gdk_pixbuf_scale_simple(pixbuf, 
-                       w, h, GDK_INTERP_BILINEAR);
-               g_object_unref(pixbuf);
-               pixbuf = t_pixbuf;
-       }
 
        /* Rotate if needed */
        if (angle != 0) {
@@ -1798,6 +1772,23 @@ GdkPixbuf *claws_load_pixbuf_fitting(GdkPixbuf *src_pixbuf, int box_width,
                pixbuf = t_pixbuf;
        }
 
+       w = gdk_pixbuf_get_width(pixbuf);
+       h = gdk_pixbuf_get_height(pixbuf);
+
+       avail_width = box_width;
+       avail_height = box_height;
+               
+       if (box_width != -1 && box_height != -1 && avail_width - 100 > 0) {
+               if (w > avail_width || h > avail_height) {
+                       h = (avail_width * h) / w;
+                       w = avail_width;
+               }
+               t_pixbuf = gdk_pixbuf_scale_simple(pixbuf, 
+                       w, h, GDK_INTERP_BILINEAR);
+               g_object_unref(pixbuf);
+               pixbuf = t_pixbuf;
+       }
+
        return pixbuf;
 }