[gnome-games] cover-loader: Use nearest neighbor for pixbuf icons up to 32px



commit c701013a66bc769ef408038afe4c7b3dff5b7e7d
Author: Adrien Plazas <kekun plazas laposte net>
Date:   Sun Nov 29 09:15:01 2020 +0100

    cover-loader: Use nearest neighbor for pixbuf icons up to 32px
    
    This avoids them to look like a blurred mess, especially as they likely
    are pixel art.

 src/core/cover-loader.vala | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
---
diff --git a/src/core/cover-loader.vala b/src/core/cover-loader.vala
index 06da6b86..1f5dba41 100644
--- a/src/core/cover-loader.vala
+++ b/src/core/cover-loader.vala
@@ -3,6 +3,7 @@
 public class Games.CoverLoader : Object {
        const double COVER_BLUR_RADIUS_FACTOR = 30.0 / 128.0;
        const double SHADOW_FACTOR = 20.0 / 128;
+       const uint TINY_ICON_SIZE = 32;
 
        public delegate void CoverReadyCallback (int scale_factor, int cover_size, Gdk.Pixbuf? cover_pixbuf, 
int icon_size, Gdk.Pixbuf? icon_pixbuf);
 
@@ -61,7 +62,10 @@ public class Games.CoverLoader : Object {
                        return null;
 
                try {
-                       pixbuf = icon_info.load_icon ();
+                       if (icon is Gdk.Pixbuf && (icon as Gdk.Pixbuf).get_width () <= TINY_ICON_SIZE)
+                               pixbuf = (icon as Gdk.Pixbuf).scale_simple (size * scale_factor, size * 
scale_factor, Gdk.InterpType.NEAREST);
+                       else
+                               pixbuf = icon_info.load_icon ();
                        save_cache_to_disk (game, pixbuf, size, scale_factor, "icons");
                }
                catch (Error e) {


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