From 40fe4fc62fdd0535b756ae01934814f37391fdcf Mon Sep 17 00:00:00 2001 From: Alx Sa Date: Thu, 13 Mar 2025 23:22:51 +0000 Subject: [PATCH] plug-ins: Convert Print Preview for images with higher bit depth Resolves #13104 print_preview_get_thumbnail () crashes when trying to display thumbnails where the image's precision is higher than 8 BPC. While the plan is to rewrite/replace this plug-in, for now, we'll duplicate the drawable's image and convert to 8BPC to prevent issues. --- plug-ins/print/print-preview.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/plug-ins/print/print-preview.c b/plug-ins/print/print-preview.c index 75f4928678..85e6d81689 100644 --- a/plug-ins/print/print-preview.c +++ b/plug-ins/print/print-preview.c @@ -831,6 +831,28 @@ print_preview_get_thumbnail (GimpDrawable *drawable, width, height, &width, &height, &bpp); + /* For now, convert preview of higher bit depth to 8BPC */ + if (bpp > 4) + { + GimpImage *temp_image; + GList *layers = NULL; + + g_bytes_unref (data); + + temp_image = + gimp_image_duplicate (gimp_item_get_image (GIMP_ITEM (drawable))); + gimp_image_convert_precision (temp_image, GIMP_PRECISION_U8_NON_LINEAR); + gimp_image_merge_visible_layers (temp_image, GIMP_CLIP_TO_IMAGE); + + layers = gimp_image_list_layers (temp_image); + data = gimp_drawable_get_thumbnail_data (GIMP_DRAWABLE (layers->data), + width, height, + &width, &height, &bpp); + + g_list_free (layers); + gimp_image_delete (temp_image); + } + switch (bpp) { case 1: