[gnome-software/gnome-3-14] screenshot image: Correctly save HiDPI images to HiDPI directories



commit 925c92528b911d10de55ba691444451e18db7029
Author: Kalev Lember <kalevlember gmail com>
Date:   Fri Mar 20 16:03:12 2015 +0100

    screenshot image: Correctly save HiDPI images to HiDPI directories
    
    Previously, we would download a HiDPI image, downscale it, save it in a
    LoDPI directory, and upscale it again to show on a HiDPI display.

 src/gs-screenshot-image.c |    9 +++++----
 1 files changed, 5 insertions(+), 4 deletions(-)
---
diff --git a/src/gs-screenshot-image.c b/src/gs-screenshot-image.c
index 953abd6..c7ff51d 100644
--- a/src/gs-screenshot-image.c
+++ b/src/gs-screenshot-image.c
@@ -239,8 +239,8 @@ gs_screenshot_image_complete_cb (SoupSession *session,
 
        /* is image size destination size unknown or exactly the correct size */
        if (priv->width == G_MAXUINT || priv->height == G_MAXUINT ||
-           (priv->width == (guint) gdk_pixbuf_get_width (pixbuf) &&
-            priv->height == (guint) gdk_pixbuf_get_height (pixbuf))) {
+           (priv->width * priv->scale == (guint) gdk_pixbuf_get_width (pixbuf) &&
+            priv->height * priv->scale == (guint) gdk_pixbuf_get_height (pixbuf))) {
                ret = g_file_set_contents (priv->filename,
                                           msg->response_body->data,
                                           msg->response_body->length,
@@ -256,7 +256,8 @@ gs_screenshot_image_complete_cb (SoupSession *session,
                im = as_image_new ();
                as_image_set_pixbuf (im, pixbuf);
                ret = as_image_save_filename (im, priv->filename,
-                                             priv->width, priv->height,
+                                             priv->width * priv->scale,
+                                             priv->height * priv->scale,
                                              AS_IMAGE_SAVE_FLAG_PAD_16_9, &error);
                if (!ret) {
                        gs_screenshot_image_set_error (ssimg, error->message);
@@ -377,7 +378,7 @@ gs_screenshot_image_load_async (GsScreenshotImage *ssimg,
        if (priv->width == G_MAXUINT || priv->height == G_MAXUINT) {
                sizedir = g_strdup ("unknown");
        } else {
-               sizedir = g_strdup_printf ("%ux%u", priv->width, priv->height);
+               sizedir = g_strdup_printf ("%ux%u", priv->width * priv->scale, priv->height * priv->scale);
        }
        cachedir = g_build_filename (priv->cachedir,
                                     "gnome-software",


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