[gimp] Issue #3041: Color Picker no longer selects Colormap entry.
- From: Jehan <jehanp src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] Issue #3041: Color Picker no longer selects Colormap entry.
- Date: Thu, 7 Mar 2019 15:57:16 +0000 (UTC)
commit e47185bf117c513298681aaed62ce5b504e9662a
Author: Jehan <jehan girinstud io>
Date: Thu Mar 7 16:55:26 2019 +0100
Issue #3041: Color Picker no longer selects Colormap entry.
This is not the ultimate fix yet, but at least a first improvement.
app/tools/gimpcolortool.c | 33 +++++++++++++++++++++++++++------
1 file changed, 27 insertions(+), 6 deletions(-)
---
diff --git a/app/tools/gimpcolortool.c b/app/tools/gimpcolortool.c
index 2e3a7bbb4d..a79f0a9fc8 100644
--- a/app/tools/gimpcolortool.c
+++ b/app/tools/gimpcolortool.c
@@ -499,18 +499,39 @@ gimp_color_tool_real_picked (GimpColorTool *color_tool,
{
GtkWidget *widget;
- if (babl_format_is_palette (sample_format))
+ widget = gimp_dialog_factory_find_widget (dialog_factory,
+ "gimp-indexed-palette");
+ if (widget)
{
- widget = gimp_dialog_factory_find_widget (dialog_factory,
- "gimp-indexed-palette");
- if (widget)
+ GtkWidget *editor = gtk_bin_get_child (GTK_BIN (widget));
+ GimpImage *image = gimp_display_get_image (display);
+
+ if (babl_format_is_palette (sample_format))
{
- GtkWidget *editor = gtk_bin_get_child (GTK_BIN (widget));
- guchar *index = pixel;
+ guchar *index = pixel;
gimp_colormap_editor_set_index (GIMP_COLORMAP_EDITOR (editor),
*index, NULL);
}
+ else if (gimp_image_get_base_type (image) == GIMP_INDEXED)
+ {
+ /* When Sample merged is set, we don't have the index
+ * information and it is possible to pick colors out of
+ * the colormap (with compositing). In such a case, the
+ * sample format will not be a palette format even though
+ * the image is indexed. Still search if the color exists
+ * in the colormap.
+ * Note that even if it does, we might still pick the
+ * wrong color, since several indexes may contain the same
+ * color and we can't know for sure which is the right
+ * one.
+ */
+ gint index = gimp_colormap_editor_get_index (GIMP_COLORMAP_EDITOR (editor),
+ color);
+ if (index > -1)
+ gimp_colormap_editor_set_index (GIMP_COLORMAP_EDITOR (editor),
+ index, NULL);
+ }
}
widget = gimp_dialog_factory_find_widget (dialog_factory,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]