aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPřemysl Eric Janouch <p@janouch.name>2023-06-13 13:20:14 +0200
committerPřemysl Eric Janouch <p@janouch.name>2023-06-13 13:21:03 +0200
commit41b5ddc744f0ee2325d2e5e9c33ca5046a6ab55d (patch)
treed26380e22ae21d8fd444554756089aebd66752ef
parentb308b5da18cae1d58c84ea7d581e2c5445886fca (diff)
downloadfiv-41b5ddc744f0ee2325d2e5e9c33ca5046a6ab55d.tar.gz
fiv-41b5ddc744f0ee2325d2e5e9c33ca5046a6ab55d.tar.xz
fiv-41b5ddc744f0ee2325d2e5e9c33ca5046a6ab55d.zip
Fix thumbnailing with the GdkPixbuf loader
-rw-r--r--fiv-io.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/fiv-io.c b/fiv-io.c
index 9b55030..2d5229d 100644
--- a/fiv-io.c
+++ b/fiv-io.c
@@ -3107,10 +3107,20 @@ open_gdkpixbuf(
gdk_pixbuf_get_bits_per_sample(pixbuf) == 8;
cairo_surface_t *surface = NULL;
- if (custom_argb32)
+ if (custom_argb32) {
surface = load_gdkpixbuf_argb32_unpremultiplied(pixbuf);
- else
- surface = gdk_cairo_surface_create_from_pixbuf(pixbuf, 1, NULL);
+ } else {
+ // Don't depend on GDK being initialized, to speed up thumbnailing
+ // (calling gdk_cairo_surface_create_from_pixbuf() would).
+ cairo_surface_t *dummy =
+ cairo_image_surface_create(CAIRO_FORMAT_ARGB32, 1, 1);
+ cairo_t *cr = cairo_create(dummy);
+ cairo_surface_destroy(dummy);
+ gdk_cairo_set_source_pixbuf(cr, pixbuf, 0, 0);
+ (void) cairo_pattern_get_surface(cairo_get_source(cr), &surface);
+ cairo_surface_reference(surface);
+ cairo_destroy(cr);
+ }
cairo_status_t surface_status = cairo_surface_status(surface);
if (surface_status != CAIRO_STATUS_SUCCESS) {