diff options
author | Richard Hughes <richard@hughsie.com> | 2018-03-09 10:23:50 +0000 |
---|---|---|
committer | Richard Hughes <richard@hughsie.com> | 2018-03-09 10:23:50 +0000 |
commit | 4acf78f426d2efb1beaa8bab74d506ea099fa5b3 (patch) | |
tree | bbfbd2a924801180460ca5e06deb73ca73fc944b | |
parent | ddd1aac8da025d95f363cb248cd37fa6d6e20302 (diff) | |
download | appstream-glib-4acf78f426d2efb1beaa8bab74d506ea099fa5b3.tar.gz |
Add AS_IMAGE_LOAD_FLAG_ALWAYS_RESIZE to always resize the pixbuf
This will of course make it look blurry in most cases.
-rw-r--r-- | libappstream-glib/as-image.c | 11 | ||||
-rw-r--r-- | libappstream-glib/as-image.h | 2 |
2 files changed, 13 insertions, 0 deletions
diff --git a/libappstream-glib/as-image.c b/libappstream-glib/as-image.c index f62aef5..6949e71 100644 --- a/libappstream-glib/as-image.c +++ b/libappstream-glib/as-image.c @@ -620,6 +620,17 @@ as_image_load_filename_full (AsImage *image, return TRUE; } + /* this makes icons look blurry, but allows the software center to look + * good as icons are properly aligned in the UI layout */ + if (flags & AS_IMAGE_LOAD_FLAG_ALWAYS_RESIZE) { + pixbuf = gdk_pixbuf_scale_simple (pixbuf_src, + (gint) dest_size, + (gint) dest_size, + GDK_INTERP_HYPER); + as_image_set_pixbuf (image, pixbuf); + return TRUE; + } + /* never scale up, just pad */ if (pixbuf_width < dest_size && pixbuf_height < dest_size) { g_debug ("icon padded to %ux%u as size %ux%u", diff --git a/libappstream-glib/as-image.h b/libappstream-glib/as-image.h index 2ec046f..9f3a3d7 100644 --- a/libappstream-glib/as-image.h +++ b/libappstream-glib/as-image.h @@ -89,6 +89,7 @@ typedef enum { * @AS_IMAGE_LOAD_FLAG_SET_BASENAME: Set the image basename * @AS_IMAGE_LOAD_FLAG_SET_CHECKSUM: Set the image checksum * @AS_IMAGE_LOAD_FLAG_ONLY_SUPPORTED: Only load supported formats like PNG and JPG + * @AS_IMAGE_LOAD_FLAG_ALWAYS_RESIZE: Always resize the source icon to the perfect size * * The flags used for loading images. **/ @@ -98,6 +99,7 @@ typedef enum { AS_IMAGE_LOAD_FLAG_SET_BASENAME = 2, /* Since: 0.5.6 */ AS_IMAGE_LOAD_FLAG_SET_CHECKSUM = 4, /* Since: 0.5.6 */ AS_IMAGE_LOAD_FLAG_ONLY_SUPPORTED = 8, /* Since: 0.5.6 */ + AS_IMAGE_LOAD_FLAG_ALWAYS_RESIZE = 16, /* Since: 0.7.7 */ /*< private >*/ AS_IMAGE_LOAD_FLAG_LAST } AsImageLoadFlags; |