[gnome-photos/wip/rishi/thumbnailer: 3/13] utils: Use a fuzz factor to decide whether a thumbnail is too small



commit 472c0c1bb933bc463023ff51531d91108e5cdbc3
Author: Debarshi Ray <debarshir gnome org>
Date:   Tue Feb 21 12:40:45 2017 +0100

    utils: Use a fuzz factor to decide whether a thumbnail is too small
    
    A grid of letterboxed thumbnails only looks good if all, or almost all,
    the thumbnails are big enough to touch at least one pair of the grid's
    edges. Sadly, sometimes, a thumbnail can be slightly smaller than the
    requested size. eg., server-generated thumbnails for remote items.
    
    Therefore, let's scale up those thumbnails that are within 75% of the
    requested size. It won't cause any discernible loss of quality and will
    make the grid look nicer.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=777869

 src/photos-utils.c |   12 ++++++++++--
 1 files changed, 10 insertions(+), 2 deletions(-)
---
diff --git a/src/photos-utils.c b/src/photos-utils.c
index 5f6e303..d514288 100644
--- a/src/photos-utils.c
+++ b/src/photos-utils.c
@@ -542,7 +542,15 @@ photos_utils_downscale_pixbuf_for_scale (GdkPixbuf *pixbuf, gint size, gint scal
   scaled_size = size * scale;
 
   /* On Hi-Dpi displays, a pixbuf should never appear smaller than on
-   * Lo-Dpi. Therefore, if a pixbuf lies between (size, size * scale)
+   * Lo-Dpi.
+   *
+   * Sometimes, a pixbuf can be slightly smaller than size. eg.,
+   * server-generated thumbnails for remote tems. Scaling them up
+   * won't cause any discernible loss of quality and will make our
+   * letterboxed grid look nicer. 75% of 'scale' has been chosen as
+   * the arbitrary definition of 'slightly smaller'.
+   *
+   * Therefore, if a pixbuf lies between (3 * size / 4, size * scale)
    * we scale it up to size * scale, so that it doesn't look smaller.
    * Similarly, if a pixbuf is smaller than size, then we increase its
    * dimensions by the scale factor.
@@ -552,7 +560,7 @@ photos_utils_downscale_pixbuf_for_scale (GdkPixbuf *pixbuf, gint size, gint scal
     {
       ret_val = g_object_ref (pixbuf);
     }
-  else if (pixbuf_size > size)
+  else if (pixbuf_size > 3 * size / 4)
     {
       if (height == width)
         {


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