From: Matthias Clasen Date: Sun, 15 Jan 2023 12:59:27 +0000 (-0500) Subject: picture: Fix hi-dpi image handling X-Git-Tag: archive/raspbian/4.12.3+ds-1+rpi1~1^2^2^2~22^2~8^2~55^2 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=cd79159420ecd3874c155ee54c0bcb54aaf52913;p=gtk4.git picture: Fix hi-dpi image handling The idea behind this code was to let scalable images (i.e. mainly SVGs) provide twice as much detail when the scale is 2. But we were also using a scaler for pngs, causing them to be too small on a hidpi screen. Fix that. Note that there are cases where you want scaling for pngs (when you display them scaled down, so the image has 'hidden' detail). But we are not attempting to handle that situation automatically. --- diff --git a/gtk/gdkpixbufutils.c b/gtk/gdkpixbufutils.c index df8c542deb..6b29128376 100644 --- a/gtk/gdkpixbufutils.c +++ b/gtk/gdkpixbufutils.c @@ -587,10 +587,12 @@ gdk_paintable_new_from_bytes_scaled (GBytes *bytes, if (gdk_texture_can_load (bytes)) { - /* We know these formats can't be scaled */ texture = gdk_texture_new_from_bytes (bytes, NULL); if (texture == NULL) return NULL; + + /* We know these formats can't be scaled */ + paintable = GDK_PAINTABLE (texture); } else { @@ -610,14 +612,14 @@ gdk_paintable_new_from_bytes_scaled (GBytes *bytes, texture = gdk_texture_new_for_pixbuf (gdk_pixbuf_loader_get_pixbuf (loader)); g_object_unref (loader); - } - if (loader_data.scale_factor != 1) - paintable = gtk_scaler_new (GDK_PAINTABLE (texture), loader_data.scale_factor); - else - paintable = g_object_ref ((GdkPaintable *)texture); + if (loader_data.scale_factor != 1) + paintable = gtk_scaler_new (GDK_PAINTABLE (texture), loader_data.scale_factor); + else + paintable = g_object_ref (GDK_PAINTABLE (texture)); - g_object_unref (texture); + g_object_unref (texture); + } return paintable; }