From 42eaf588fde9d44d6b7ccd9cdb7eacfab35fe210 Mon Sep 17 00:00:00 2001 From: Jehan Date: Mon, 5 Feb 2018 15:00:17 +0100 Subject: [PATCH] plug-ins: ico export crashes on indexed images. It seems the current code simply forgot to break on indexed types and therefore hit some g_return_*if_reached() code breaking the logics. Looking further, I see some code taking care of indexed images and converting them to RGB. And testing after adding breaks looks like it works just fine. So I am assuming this was just forgotten breaks indeed, and not on purpose not allowing indexed images (if that were the intent though, this is not how it should be done). --- plug-ins/file-ico/ico-dialog.c | 1 + plug-ins/file-ico/ico-save.c | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/plug-ins/file-ico/ico-dialog.c b/plug-ins/file-ico/ico-dialog.c index 8038d0ff6b..1667dc6af7 100644 --- a/plug-ins/file-ico/ico-dialog.c +++ b/plug-ins/file-ico/ico-dialog.c @@ -258,6 +258,7 @@ ico_dialog_update_icon_preview (GtkWidget *dialog, case GIMP_INDEXED_IMAGE: case GIMP_INDEXEDA_IMAGE: format = gimp_drawable_get_format (layer); + break; default: g_return_if_reached (); diff --git a/plug-ins/file-ico/ico-save.c b/plug-ins/file-ico/ico-save.c index d599788eb4..6d19e166a7 100644 --- a/plug-ins/file-ico/ico-save.c +++ b/plug-ins/file-ico/ico-save.c @@ -464,6 +464,10 @@ ico_get_layer_num_colors (gint32 layer, case GIMP_INDEXED_IMAGE: case GIMP_INDEXEDA_IMAGE: format = gegl_buffer_get_format (buffer); + /* It is possible to count the colors of indexed image more easily + * with gimp_image_get_colormap(), but counting only the colors + * actually used will allow more efficient bpp if possible. */ + break; default: g_return_val_if_reached (0); @@ -599,6 +603,7 @@ ico_image_get_reduced_buf (guint32 layer, case GIMP_INDEXED_IMAGE: case GIMP_INDEXEDA_IMAGE: format = gegl_buffer_get_format (buffer); + break; default: g_return_if_reached ();