[gnome-photos/wip/rishi/thumbnailer: 2/13] base-item: Center the thumbnails in an imaginary 256x256 grid



commit 38147331766a947f1a7186de719f180dbc46834a
Author: Debarshi Ray <debarshir gnome org>
Date:   Tue Feb 21 12:18:34 2017 +0100

    base-item: Center the thumbnails in an imaginary 256x256 grid
    
    This is done by copying thumbnails that are smaller than the requested
    size to the center of 256x256 GdkPixbuf. As a nice side-effect, emblems
    are no longer scaled down for such thumbnails.
    
    This will help letterbox the thumbnails.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=740417
    https://bugzilla.gnome.org/show_bug.cgi?id=777869

 src/photos-base-item.c |    7 ++++++-
 1 files changed, 6 insertions(+), 1 deletions(-)
---
diff --git a/src/photos-base-item.c b/src/photos-base-item.c
index f6fbaef..713fdd4 100644
--- a/src/photos-base-item.c
+++ b/src/photos-base-item.c
@@ -779,6 +779,7 @@ photos_base_item_refresh_thumb_path_pixbuf (GObject *source_object, GAsyncResult
   PhotosBaseItem *self;
   PhotosBaseItemPrivate *priv;
   GApplication *app;
+  GdkPixbuf *centered_pixbuf = NULL;
   GdkPixbuf *pixbuf = NULL;
   GdkPixbuf *scaled_pixbuf = NULL;
   GError *error = NULL;
@@ -823,10 +824,14 @@ photos_base_item_refresh_thumb_path_pixbuf (GObject *source_object, GAsyncResult
   scale = photos_application_get_scale_factor (PHOTOS_APPLICATION (app));
   icon_size = photos_utils_get_icon_size_unscaled ();
   scaled_pixbuf = photos_utils_downscale_pixbuf_for_scale (pixbuf, icon_size, scale);
-  photos_base_item_set_original_icon (self, scaled_pixbuf);
+
+  icon_size = photos_utils_get_icon_size ();
+  centered_pixbuf = photos_utils_center_pixbuf (scaled_pixbuf, icon_size);
+  photos_base_item_set_original_icon (self, centered_pixbuf);
 
  out:
   g_input_stream_close_async (stream, G_PRIORITY_DEFAULT, NULL, NULL, NULL);
+  g_clear_object (&centered_pixbuf);
   g_clear_object (&scaled_pixbuf);
   g_clear_object (&pixbuf);
 }


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