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.
This commit is contained in:
Matthias Clasen 2023-01-15 07:59:27 -05:00
parent 071c6c60c0
commit cd79159420

View File

@ -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);
paintable = g_object_ref (GDK_PAINTABLE (texture));
g_object_unref (texture);
}
return paintable;
}