mirror of
https://gitlab.gnome.org/GNOME/gimp.git
synced 2025-07-04 01:43:24 +00:00
app: some more GimpRGB to GeglColor port.
The picked() signal of GimpColorTool now emit a GeglColor.
This commit is contained in:
parent
ecf4cfb3c5
commit
39544f96b4
17 changed files with 120 additions and 78 deletions
|
@ -67,7 +67,7 @@ static void context_select_color (GimpActionSelectType select_type,
|
||||||
|
|
||||||
static gint context_get_color_index (gboolean use_colormap,
|
static gint context_get_color_index (gboolean use_colormap,
|
||||||
gboolean use_palette,
|
gboolean use_palette,
|
||||||
const GimpRGB *color);
|
GeglColor *color);
|
||||||
static gint context_max_color_index (gboolean use_colormap,
|
static gint context_max_color_index (gboolean use_colormap,
|
||||||
gboolean use_palette);
|
gboolean use_palette);
|
||||||
static gboolean context_set_color_index (gint index,
|
static gboolean context_set_color_index (gint index,
|
||||||
|
@ -868,13 +868,16 @@ context_paint_mode_index (GimpLayerMode paint_mode,
|
||||||
|
|
||||||
static void
|
static void
|
||||||
context_select_color (GimpActionSelectType select_type,
|
context_select_color (GimpActionSelectType select_type,
|
||||||
GimpRGB *color,
|
GimpRGB *rgb,
|
||||||
gboolean use_colormap,
|
gboolean use_colormap,
|
||||||
gboolean use_palette)
|
gboolean use_palette)
|
||||||
{
|
{
|
||||||
gint index;
|
GeglColor *color;
|
||||||
gint max;
|
gint index;
|
||||||
|
gint max;
|
||||||
|
|
||||||
|
color = gegl_color_new ("black");
|
||||||
|
gegl_color_set_rgba_with_space (color, rgb->r, rgb->g, rgb->b, rgb->a, NULL);
|
||||||
index = context_get_color_index (use_colormap, use_palette, color);
|
index = context_get_color_index (use_colormap, use_palette, color);
|
||||||
max = context_max_color_index (use_colormap, use_palette);
|
max = context_max_color_index (use_colormap, use_palette);
|
||||||
|
|
||||||
|
@ -883,13 +886,15 @@ context_select_color (GimpActionSelectType select_type,
|
||||||
0, max, 0,
|
0, max, 0,
|
||||||
0, 1, 4, 0, FALSE);
|
0, 1, 4, 0, FALSE);
|
||||||
|
|
||||||
context_set_color_index (index, use_colormap, use_palette, color);
|
context_set_color_index (index, use_colormap, use_palette, rgb);
|
||||||
|
|
||||||
|
g_object_unref (color);
|
||||||
}
|
}
|
||||||
|
|
||||||
static gint
|
static gint
|
||||||
context_get_color_index (gboolean use_colormap,
|
context_get_color_index (gboolean use_colormap,
|
||||||
gboolean use_palette,
|
gboolean use_palette,
|
||||||
const GimpRGB *color)
|
GeglColor *color)
|
||||||
{
|
{
|
||||||
if (use_colormap)
|
if (use_colormap)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1305,15 +1305,20 @@ gimp_palette_load_css (GimpContext *context,
|
||||||
|
|
||||||
if (g_regex_match (regex, buf, 0, &matches))
|
if (g_regex_match (regex, buf, 0, &matches))
|
||||||
{
|
{
|
||||||
GimpRGB color;
|
GimpRGB rgb;
|
||||||
gchar *word = g_match_info_fetch_named (matches, "param");
|
gchar *word = g_match_info_fetch_named (matches, "param");
|
||||||
|
|
||||||
if (gimp_rgb_parse_css (&color, word, -1))
|
if (gimp_rgb_parse_css (&rgb, word, -1))
|
||||||
{
|
{
|
||||||
if (! gimp_palette_find_entry (palette, &color, NULL))
|
GeglColor *color = gegl_color_new ("black");
|
||||||
|
|
||||||
|
gegl_color_set_rgba_with_space (color, rgb.r, rgb.g, rgb.b, rgb.a, NULL);
|
||||||
|
if (! gimp_palette_find_entry (palette, color, NULL))
|
||||||
{
|
{
|
||||||
gimp_palette_add_entry (palette, -1, NULL, &color);
|
gimp_palette_add_entry (palette, -1, NULL, &rgb);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
g_object_unref (color);
|
||||||
}
|
}
|
||||||
|
|
||||||
g_free (word);
|
g_free (word);
|
||||||
|
|
|
@ -642,14 +642,19 @@ gimp_palette_get_columns (GimpPalette *palette)
|
||||||
|
|
||||||
GimpPaletteEntry *
|
GimpPaletteEntry *
|
||||||
gimp_palette_find_entry (GimpPalette *palette,
|
gimp_palette_find_entry (GimpPalette *palette,
|
||||||
const GimpRGB *color,
|
GeglColor *color,
|
||||||
GimpPaletteEntry *start_from)
|
GimpPaletteEntry *start_from)
|
||||||
{
|
{
|
||||||
GimpPaletteEntry *entry;
|
GimpPaletteEntry *entry;
|
||||||
|
GimpRGB rgb;
|
||||||
|
|
||||||
g_return_val_if_fail (GIMP_IS_PALETTE (palette), NULL);
|
g_return_val_if_fail (GIMP_IS_PALETTE (palette), NULL);
|
||||||
g_return_val_if_fail (color != NULL, NULL);
|
g_return_val_if_fail (GEGL_IS_COLOR (color), NULL);
|
||||||
|
|
||||||
|
/* TODO: we should have a gimp_color_distance() function to compare 2
|
||||||
|
* GeglColor.
|
||||||
|
*/
|
||||||
|
gegl_color_get_rgba_with_space (color, &rgb.r, &rgb.g, &rgb.b, &rgb.a, NULL);
|
||||||
if (! start_from)
|
if (! start_from)
|
||||||
{
|
{
|
||||||
GList *list;
|
GList *list;
|
||||||
|
@ -659,11 +664,11 @@ gimp_palette_find_entry (GimpPalette *palette,
|
||||||
for (list = palette->colors; list; list = g_list_next (list))
|
for (list = palette->colors; list; list = g_list_next (list))
|
||||||
{
|
{
|
||||||
entry = (GimpPaletteEntry *) list->data;
|
entry = (GimpPaletteEntry *) list->data;
|
||||||
if (gimp_rgb_distance (&entry->color, color) < RGB_EPSILON)
|
if (gimp_rgb_distance (&entry->color, &rgb) < RGB_EPSILON)
|
||||||
return entry;
|
return entry;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (gimp_rgb_distance (&start_from->color, color) < RGB_EPSILON)
|
else if (gimp_rgb_distance (&start_from->color, &rgb) < RGB_EPSILON)
|
||||||
{
|
{
|
||||||
return start_from;
|
return start_from;
|
||||||
}
|
}
|
||||||
|
@ -685,7 +690,7 @@ gimp_palette_find_entry (GimpPalette *palette,
|
||||||
if (next)
|
if (next)
|
||||||
{
|
{
|
||||||
entry = (GimpPaletteEntry *) next->data;
|
entry = (GimpPaletteEntry *) next->data;
|
||||||
if (gimp_rgb_distance (&entry->color, color) < RGB_EPSILON)
|
if (gimp_rgb_distance (&entry->color, &rgb) < RGB_EPSILON)
|
||||||
return entry;
|
return entry;
|
||||||
|
|
||||||
next = next->next;
|
next = next->next;
|
||||||
|
@ -694,7 +699,7 @@ gimp_palette_find_entry (GimpPalette *palette,
|
||||||
if (prev)
|
if (prev)
|
||||||
{
|
{
|
||||||
entry = (GimpPaletteEntry *) prev->data;
|
entry = (GimpPaletteEntry *) prev->data;
|
||||||
if (gimp_rgb_distance (&entry->color, color) < RGB_EPSILON)
|
if (gimp_rgb_distance (&entry->color, &rgb) < RGB_EPSILON)
|
||||||
return entry;
|
return entry;
|
||||||
|
|
||||||
prev = prev->prev;
|
prev = prev->prev;
|
||||||
|
|
|
@ -99,7 +99,7 @@ void gimp_palette_set_columns (GimpPalette *palette,
|
||||||
gint gimp_palette_get_columns (GimpPalette *palette);
|
gint gimp_palette_get_columns (GimpPalette *palette);
|
||||||
|
|
||||||
GimpPaletteEntry * gimp_palette_find_entry (GimpPalette *palette,
|
GimpPaletteEntry * gimp_palette_find_entry (GimpPalette *palette,
|
||||||
const GimpRGB *color,
|
GeglColor *color,
|
||||||
GimpPaletteEntry *start_from);
|
GimpPaletteEntry *start_from);
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -72,7 +72,7 @@ static void gimp_color_picker_tool_picked (GimpColorTool *color_t
|
||||||
GimpColorPickState pick_state,
|
GimpColorPickState pick_state,
|
||||||
const Babl *sample_format,
|
const Babl *sample_format,
|
||||||
gpointer pixel,
|
gpointer pixel,
|
||||||
const GimpRGB *color);
|
GeglColor *color);
|
||||||
|
|
||||||
static void gimp_color_picker_tool_info_create (GimpColorPickerTool *picker_tool,
|
static void gimp_color_picker_tool_info_create (GimpColorPickerTool *picker_tool,
|
||||||
GimpDisplay *display);
|
GimpDisplay *display);
|
||||||
|
@ -84,7 +84,7 @@ static void gimp_color_picker_tool_info_update (GimpColorPickerTool *picker_
|
||||||
gboolean sample_average,
|
gboolean sample_average,
|
||||||
const Babl *sample_format,
|
const Babl *sample_format,
|
||||||
gpointer pixel,
|
gpointer pixel,
|
||||||
const GimpRGB *color,
|
GeglColor *color,
|
||||||
gint x,
|
gint x,
|
||||||
gint y);
|
gint y);
|
||||||
|
|
||||||
|
@ -300,7 +300,7 @@ gimp_color_picker_tool_picked (GimpColorTool *color_tool,
|
||||||
GimpColorPickState pick_state,
|
GimpColorPickState pick_state,
|
||||||
const Babl *sample_format,
|
const Babl *sample_format,
|
||||||
gpointer pixel,
|
gpointer pixel,
|
||||||
const GimpRGB *color)
|
GeglColor *color)
|
||||||
{
|
{
|
||||||
GimpColorPickerTool *picker_tool = GIMP_COLOR_PICKER_TOOL (color_tool);
|
GimpColorPickerTool *picker_tool = GIMP_COLOR_PICKER_TOOL (color_tool);
|
||||||
GimpColorPickerOptions *options;
|
GimpColorPickerOptions *options;
|
||||||
|
@ -428,13 +428,14 @@ gimp_color_picker_tool_info_update (GimpColorPickerTool *picker_tool,
|
||||||
gboolean sample_average,
|
gboolean sample_average,
|
||||||
const Babl *sample_format,
|
const Babl *sample_format,
|
||||||
gpointer pixel,
|
gpointer pixel,
|
||||||
const GimpRGB *color,
|
GeglColor *color,
|
||||||
gint x,
|
gint x,
|
||||||
gint y)
|
gint y)
|
||||||
{
|
{
|
||||||
GimpTool *tool = GIMP_TOOL (picker_tool);
|
GimpTool *tool = GIMP_TOOL (picker_tool);
|
||||||
GimpImage *image = gimp_display_get_image (display);
|
GimpImage *image = gimp_display_get_image (display);
|
||||||
GList *drawables = gimp_image_get_selected_drawables (image);
|
GList *drawables = gimp_image_get_selected_drawables (image);
|
||||||
|
GimpRGB rgb;
|
||||||
|
|
||||||
tool->display = display;
|
tool->display = display;
|
||||||
|
|
||||||
|
@ -443,14 +444,15 @@ gimp_color_picker_tool_info_update (GimpColorPickerTool *picker_tool,
|
||||||
gimp_tool_gui_set_viewables (picker_tool->gui, drawables);
|
gimp_tool_gui_set_viewables (picker_tool->gui, drawables);
|
||||||
g_list_free (drawables);
|
g_list_free (drawables);
|
||||||
|
|
||||||
|
gegl_color_get_rgba_with_space (color, &rgb.r, &rgb.g, &rgb.b, &rgb.a, NULL);
|
||||||
gimp_color_area_set_color (GIMP_COLOR_AREA (picker_tool->color_area),
|
gimp_color_area_set_color (GIMP_COLOR_AREA (picker_tool->color_area),
|
||||||
color);
|
&rgb);
|
||||||
|
|
||||||
gimp_color_frame_set_color (GIMP_COLOR_FRAME (picker_tool->color_frame1),
|
gimp_color_frame_set_color (GIMP_COLOR_FRAME (picker_tool->color_frame1),
|
||||||
sample_average, sample_format, pixel, color,
|
sample_average, sample_format, pixel, &rgb,
|
||||||
x, y);
|
x, y);
|
||||||
gimp_color_frame_set_color (GIMP_COLOR_FRAME (picker_tool->color_frame2),
|
gimp_color_frame_set_color (GIMP_COLOR_FRAME (picker_tool->color_frame2),
|
||||||
sample_average, sample_format, pixel, color,
|
sample_average, sample_format, pixel, &rgb,
|
||||||
x, y);
|
x, y);
|
||||||
|
|
||||||
gimp_tool_gui_show (picker_tool->gui);
|
gimp_tool_gui_show (picker_tool->gui);
|
||||||
|
|
|
@ -113,7 +113,7 @@ static void gimp_color_tool_real_picked (GimpColorTool *color_tool,
|
||||||
GimpColorPickState pick_state,
|
GimpColorPickState pick_state,
|
||||||
const Babl *sample_format,
|
const Babl *sample_format,
|
||||||
gpointer pixel,
|
gpointer pixel,
|
||||||
const GimpRGB *color);
|
GeglColor *color);
|
||||||
|
|
||||||
static gboolean gimp_color_tool_can_pick (GimpColorTool *tool,
|
static gboolean gimp_color_tool_can_pick (GimpColorTool *tool,
|
||||||
const GimpCoords *coords,
|
const GimpCoords *coords,
|
||||||
|
@ -151,7 +151,7 @@ gimp_color_tool_class_init (GimpColorToolClass *klass)
|
||||||
GIMP_TYPE_COLOR_PICK_STATE,
|
GIMP_TYPE_COLOR_PICK_STATE,
|
||||||
G_TYPE_POINTER,
|
G_TYPE_POINTER,
|
||||||
G_TYPE_POINTER,
|
G_TYPE_POINTER,
|
||||||
GIMP_TYPE_RGB | G_SIGNAL_TYPE_STATIC_SCOPE);
|
GEGL_TYPE_COLOR);
|
||||||
|
|
||||||
object_class->finalize = gimp_color_tool_finalize;
|
object_class->finalize = gimp_color_tool_finalize;
|
||||||
|
|
||||||
|
@ -485,13 +485,16 @@ gimp_color_tool_real_picked (GimpColorTool *color_tool,
|
||||||
GimpColorPickState pick_state,
|
GimpColorPickState pick_state,
|
||||||
const Babl *sample_format,
|
const Babl *sample_format,
|
||||||
gpointer pixel,
|
gpointer pixel,
|
||||||
const GimpRGB *color)
|
GeglColor *color)
|
||||||
{
|
{
|
||||||
GimpTool *tool = GIMP_TOOL (color_tool);
|
GimpTool *tool = GIMP_TOOL (color_tool);
|
||||||
GimpDisplayShell *shell = gimp_display_get_shell (display);
|
GimpDisplayShell *shell = gimp_display_get_shell (display);
|
||||||
GimpImageWindow *image_window;
|
GimpImageWindow *image_window;
|
||||||
GimpDialogFactory *dialog_factory;
|
GimpDialogFactory *dialog_factory;
|
||||||
GimpContext *context;
|
GimpContext *context;
|
||||||
|
GimpRGB rgb = { 0 };
|
||||||
|
|
||||||
|
g_return_if_fail (GEGL_IS_COLOR (color));
|
||||||
|
|
||||||
image_window = gimp_display_shell_get_window (shell);
|
image_window = gimp_display_shell_get_window (shell);
|
||||||
dialog_factory = gimp_dock_container_get_dialog_factory (GIMP_DOCK_CONTAINER (image_window));
|
dialog_factory = gimp_dock_container_get_dialog_factory (GIMP_DOCK_CONTAINER (image_window));
|
||||||
|
@ -554,17 +557,19 @@ gimp_color_tool_real_picked (GimpColorTool *color_tool,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gegl_color_get_rgba_with_space (color, &rgb.r, &rgb.g, &rgb.b, &rgb.a, sample_format);
|
||||||
switch (color_tool->pick_target)
|
switch (color_tool->pick_target)
|
||||||
{
|
{
|
||||||
case GIMP_COLOR_PICK_TARGET_NONE:
|
case GIMP_COLOR_PICK_TARGET_NONE:
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case GIMP_COLOR_PICK_TARGET_FOREGROUND:
|
case GIMP_COLOR_PICK_TARGET_FOREGROUND:
|
||||||
gimp_context_set_foreground (context, color);
|
/* TODO: FG/BG colors should be stored as GeglColor. */
|
||||||
|
gimp_context_set_foreground (context, &rgb);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case GIMP_COLOR_PICK_TARGET_BACKGROUND:
|
case GIMP_COLOR_PICK_TARGET_BACKGROUND:
|
||||||
gimp_context_set_background (context, color);
|
gimp_context_set_background (context, &rgb);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case GIMP_COLOR_PICK_TARGET_PALETTE:
|
case GIMP_COLOR_PICK_TARGET_PALETTE:
|
||||||
|
@ -636,15 +641,9 @@ gimp_color_tool_pick (GimpColorTool *tool,
|
||||||
|
|
||||||
if (klass->pick &&
|
if (klass->pick &&
|
||||||
klass->pick (tool, coords, display, &sample_format, pixel, &color))
|
klass->pick (tool, coords, display, &sample_format, pixel, &color))
|
||||||
{
|
g_signal_emit (tool, gimp_color_tool_signals[PICKED], 0,
|
||||||
GimpRGB rgb;
|
coords, display, pick_state,
|
||||||
|
sample_format, pixel, color);
|
||||||
gegl_color_get_rgba_with_space (color, &rgb.r, &rgb.g, &rgb.b, &rgb.a, NULL);
|
|
||||||
/* TODO: the "picked" signal should emit a GeglColor. */
|
|
||||||
g_signal_emit (tool, gimp_color_tool_signals[PICKED], 0,
|
|
||||||
coords, display, pick_state,
|
|
||||||
sample_format, pixel, &rgb);
|
|
||||||
}
|
|
||||||
|
|
||||||
g_object_unref (color);
|
g_object_unref (color);
|
||||||
}
|
}
|
||||||
|
|
|
@ -72,7 +72,7 @@ struct _GimpColorToolClass
|
||||||
GimpColorPickState pick_state,
|
GimpColorPickState pick_state,
|
||||||
const Babl *sample_format,
|
const Babl *sample_format,
|
||||||
gpointer pixel,
|
gpointer pixel,
|
||||||
const GimpRGB *color);
|
GeglColor *color);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -144,7 +144,7 @@ static void gimp_filter_tool_color_picked (GimpColorTool *color_too
|
||||||
GimpColorPickState pick_state,
|
GimpColorPickState pick_state,
|
||||||
const Babl *sample_format,
|
const Babl *sample_format,
|
||||||
gpointer pixel,
|
gpointer pixel,
|
||||||
const GimpRGB *color);
|
GeglColor *color);
|
||||||
|
|
||||||
static void gimp_filter_tool_real_reset (GimpFilterTool *filter_tool);
|
static void gimp_filter_tool_real_reset (GimpFilterTool *filter_tool);
|
||||||
static void gimp_filter_tool_real_set_config(GimpFilterTool *filter_tool,
|
static void gimp_filter_tool_real_set_config(GimpFilterTool *filter_tool,
|
||||||
|
@ -859,9 +859,12 @@ gimp_filter_tool_color_picked (GimpColorTool *color_tool,
|
||||||
GimpColorPickState pick_state,
|
GimpColorPickState pick_state,
|
||||||
const Babl *sample_format,
|
const Babl *sample_format,
|
||||||
gpointer pixel,
|
gpointer pixel,
|
||||||
const GimpRGB *color)
|
GeglColor *color)
|
||||||
{
|
{
|
||||||
GimpFilterTool *filter_tool = GIMP_FILTER_TOOL (color_tool);
|
GimpFilterTool *filter_tool = GIMP_FILTER_TOOL (color_tool);
|
||||||
|
GimpRGB rgb;
|
||||||
|
|
||||||
|
gegl_color_get_rgba_with_space (color, &rgb.r, &rgb.g, &rgb.b, &rgb.a, NULL);
|
||||||
|
|
||||||
if (filter_tool->active_picker)
|
if (filter_tool->active_picker)
|
||||||
{
|
{
|
||||||
|
@ -879,7 +882,7 @@ gimp_filter_tool_color_picked (GimpColorTool *color_tool,
|
||||||
filter_tool->pick_identifier,
|
filter_tool->pick_identifier,
|
||||||
coords->x,
|
coords->x,
|
||||||
coords->y,
|
coords->y,
|
||||||
sample_format, color);
|
sample_format, &rgb);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -889,7 +892,7 @@ gimp_filter_tool_color_picked (GimpColorTool *color_tool,
|
||||||
filter_tool->pick_identifier,
|
filter_tool->pick_identifier,
|
||||||
coords->x,
|
coords->x,
|
||||||
coords->y,
|
coords->y,
|
||||||
sample_format, color);
|
sample_format, &rgb);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
|
@ -487,8 +487,9 @@ gimp_color_history_palette_dirty (GimpColorHistory *history)
|
||||||
for (i = 0; i < history->history_size; i++)
|
for (i = 0; i < history->history_size; i++)
|
||||||
{
|
{
|
||||||
GimpPaletteEntry *entry = gimp_palette_get_entry (palette, i);
|
GimpPaletteEntry *entry = gimp_palette_get_entry (palette, i);
|
||||||
|
GeglColor *color = gegl_color_new ("black");
|
||||||
GimpRGB black = { 0.0, 0.0, 0.0, 1.0 };
|
GimpRGB black = { 0.0, 0.0, 0.0, 1.0 };
|
||||||
GimpRGB color = entry ? entry->color : black;
|
GimpRGB rgb = entry ? entry->color : black;
|
||||||
gboolean oog = FALSE;
|
gboolean oog = FALSE;
|
||||||
|
|
||||||
g_signal_handlers_block_by_func (history->color_areas[i],
|
g_signal_handlers_block_by_func (history->color_areas[i],
|
||||||
|
@ -496,24 +497,28 @@ gimp_color_history_palette_dirty (GimpColorHistory *history)
|
||||||
GINT_TO_POINTER (i));
|
GINT_TO_POINTER (i));
|
||||||
|
|
||||||
gimp_color_area_set_color (GIMP_COLOR_AREA (history->color_areas[i]),
|
gimp_color_area_set_color (GIMP_COLOR_AREA (history->color_areas[i]),
|
||||||
&color);
|
&rgb);
|
||||||
|
|
||||||
|
gegl_color_set_rgba_with_space (color, rgb.r, rgb.g, rgb.b, rgb.a, NULL);
|
||||||
if (/* Common out-of-gamut case */
|
if (/* Common out-of-gamut case */
|
||||||
(color.r < 0.0 || color.r > 1.0 ||
|
(rgb.r < 0.0 || rgb.r > 1.0 ||
|
||||||
color.g < 0.0 || color.g > 1.0 ||
|
rgb.g < 0.0 || rgb.g > 1.0 ||
|
||||||
color.b < 0.0 || color.b > 1.0) ||
|
rgb.b < 0.0 || rgb.b > 1.0) ||
|
||||||
/* Indexed images */
|
/* Indexed images */
|
||||||
(colormap_palette && ! gimp_palette_find_entry (colormap_palette, &color, NULL)) ||
|
(colormap_palette && ! gimp_palette_find_entry (colormap_palette, color, NULL)) ||
|
||||||
/* Grayscale images */
|
/* Grayscale images */
|
||||||
(base_type == GIMP_GRAY &&
|
(base_type == GIMP_GRAY &&
|
||||||
(ABS (color.r - color.g) > CHANNEL_EPSILON ||
|
(ABS (rgb.r - rgb.g) > CHANNEL_EPSILON ||
|
||||||
ABS (color.r - color.b) > CHANNEL_EPSILON ||
|
ABS (rgb.r - rgb.b) > CHANNEL_EPSILON ||
|
||||||
ABS (color.g - color.b) > CHANNEL_EPSILON)))
|
ABS (rgb.g - rgb.b) > CHANNEL_EPSILON)))
|
||||||
oog = TRUE;
|
oog = TRUE;
|
||||||
gimp_color_area_set_out_of_gamut (GIMP_COLOR_AREA (history->color_areas[i]), oog);
|
gimp_color_area_set_out_of_gamut (GIMP_COLOR_AREA (history->color_areas[i]), oog);
|
||||||
|
|
||||||
g_signal_handlers_unblock_by_func (history->color_areas[i],
|
g_signal_handlers_unblock_by_func (history->color_areas[i],
|
||||||
gimp_color_history_color_changed,
|
gimp_color_history_color_changed,
|
||||||
GINT_TO_POINTER (i));
|
GINT_TO_POINTER (i));
|
||||||
|
|
||||||
|
g_object_unref (color);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -326,7 +326,7 @@ gimp_colormap_editor_is_color_deletable (GimpColormapEditor *editor)
|
||||||
|
|
||||||
gint
|
gint
|
||||||
gimp_colormap_editor_get_index (GimpColormapEditor *editor,
|
gimp_colormap_editor_get_index (GimpColormapEditor *editor,
|
||||||
const GimpRGB *search)
|
GeglColor *search)
|
||||||
{
|
{
|
||||||
g_return_val_if_fail (GIMP_IS_COLORMAP_EDITOR (editor), 0);
|
g_return_val_if_fail (GIMP_IS_COLORMAP_EDITOR (editor), 0);
|
||||||
|
|
||||||
|
|
|
@ -55,7 +55,7 @@ void gimp_colormap_editor_delete_color (GimpColormapEditor *editor)
|
||||||
gboolean gimp_colormap_editor_is_color_deletable (GimpColormapEditor *editor);
|
gboolean gimp_colormap_editor_is_color_deletable (GimpColormapEditor *editor);
|
||||||
|
|
||||||
gint gimp_colormap_editor_get_index (GimpColormapEditor *editor,
|
gint gimp_colormap_editor_get_index (GimpColormapEditor *editor,
|
||||||
const GimpRGB *search);
|
GeglColor *search);
|
||||||
gboolean gimp_colormap_editor_set_index (GimpColormapEditor *editor,
|
gboolean gimp_colormap_editor_set_index (GimpColormapEditor *editor,
|
||||||
gint index,
|
gint index,
|
||||||
GimpRGB *color);
|
GimpRGB *color);
|
||||||
|
|
|
@ -368,7 +368,7 @@ gimp_colormap_selection_new (GimpContext *context)
|
||||||
|
|
||||||
gint
|
gint
|
||||||
gimp_colormap_selection_get_index (GimpColormapSelection *selection,
|
gimp_colormap_selection_get_index (GimpColormapSelection *selection,
|
||||||
const GimpRGB *search)
|
GeglColor *search)
|
||||||
{
|
{
|
||||||
GimpImage *image;
|
GimpImage *image;
|
||||||
gint index;
|
gint index;
|
||||||
|
@ -385,10 +385,16 @@ gimp_colormap_selection_get_index (GimpColormapSelection *selection,
|
||||||
if (search)
|
if (search)
|
||||||
{
|
{
|
||||||
GimpRGB temp;
|
GimpRGB temp;
|
||||||
|
GimpRGB search_rgb;
|
||||||
|
|
||||||
|
/* TODO: this is likely very wrong as we don't seem to care about the
|
||||||
|
* color space of neither search nor temp. They should be fit into a same
|
||||||
|
* space before comparing.
|
||||||
|
*/
|
||||||
|
gegl_color_get_rgba_with_space (search, &search_rgb.r, &search_rgb.g, &search_rgb.b, &search_rgb.a, NULL);
|
||||||
gimp_image_get_colormap_entry (image, index, &temp);
|
gimp_image_get_colormap_entry (image, index, &temp);
|
||||||
|
|
||||||
if (gimp_rgb_distance (&temp, search) > RGB_EPSILON)
|
if (gimp_rgb_distance (&temp, &search_rgb) > RGB_EPSILON)
|
||||||
{
|
{
|
||||||
gint n_colors = gimp_image_get_colormap_size (image);
|
gint n_colors = gimp_image_get_colormap_size (image);
|
||||||
gint i;
|
gint i;
|
||||||
|
@ -397,7 +403,7 @@ gimp_colormap_selection_get_index (GimpColormapSelection *selection,
|
||||||
{
|
{
|
||||||
gimp_image_get_colormap_entry (image, i, &temp);
|
gimp_image_get_colormap_entry (image, i, &temp);
|
||||||
|
|
||||||
if (gimp_rgb_distance (&temp, search) < RGB_EPSILON)
|
if (gimp_rgb_distance (&temp, &search_rgb) < RGB_EPSILON)
|
||||||
{
|
{
|
||||||
index = i;
|
index = i;
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -67,7 +67,7 @@ GType gimp_colormap_selection_get_type (void) G_GNUC_CONST;
|
||||||
GtkWidget * gimp_colormap_selection_new (GimpContext *context);
|
GtkWidget * gimp_colormap_selection_new (GimpContext *context);
|
||||||
|
|
||||||
gint gimp_colormap_selection_get_index (GimpColormapSelection *selection,
|
gint gimp_colormap_selection_get_index (GimpColormapSelection *selection,
|
||||||
const GimpRGB *search);
|
GeglColor *search);
|
||||||
gboolean gimp_colormap_selection_set_index (GimpColormapSelection *selection,
|
gboolean gimp_colormap_selection_set_index (GimpColormapSelection *selection,
|
||||||
gint index,
|
gint index,
|
||||||
GimpRGB *color);
|
GimpRGB *color);
|
||||||
|
|
|
@ -86,13 +86,17 @@ gimp_color_selector_palette_set_color (GimpColorSelector *selector,
|
||||||
if (palette && gimp_palette_get_n_colors (palette) > 0)
|
if (palette && gimp_palette_get_n_colors (palette) > 0)
|
||||||
{
|
{
|
||||||
GimpPaletteEntry *entry;
|
GimpPaletteEntry *entry;
|
||||||
|
GeglColor *color = gegl_color_new ("black");
|
||||||
|
|
||||||
entry = gimp_palette_find_entry (palette, rgb,
|
gegl_color_set_rgba_with_space (color, rgb->r, rgb->g, rgb->b, rgb->a, NULL);
|
||||||
|
entry = gimp_palette_find_entry (palette, color,
|
||||||
GIMP_PALETTE_VIEW (select->view)->selected);
|
GIMP_PALETTE_VIEW (select->view)->selected);
|
||||||
|
|
||||||
if (entry)
|
if (entry)
|
||||||
gimp_palette_view_select_entry (GIMP_PALETTE_VIEW (select->view),
|
gimp_palette_view_select_entry (GIMP_PALETTE_VIEW (select->view),
|
||||||
entry);
|
entry);
|
||||||
|
|
||||||
|
g_object_unref (color);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -869,7 +869,7 @@ gimp_fg_bg_editor_image_changed (GimpFgBgEditor *editor,
|
||||||
static void
|
static void
|
||||||
gimp_fg_bg_editor_draw_color_frame (GimpFgBgEditor *editor,
|
gimp_fg_bg_editor_draw_color_frame (GimpFgBgEditor *editor,
|
||||||
cairo_t *cr,
|
cairo_t *cr,
|
||||||
const GimpRGB *color,
|
const GimpRGB *rgb,
|
||||||
gint x,
|
gint x,
|
||||||
gint y,
|
gint y,
|
||||||
gint width,
|
gint width,
|
||||||
|
@ -877,6 +877,7 @@ gimp_fg_bg_editor_draw_color_frame (GimpFgBgEditor *editor,
|
||||||
gint corner_dx,
|
gint corner_dx,
|
||||||
gint corner_dy)
|
gint corner_dy)
|
||||||
{
|
{
|
||||||
|
GeglColor *color;
|
||||||
GimpPalette *colormap_palette = NULL;
|
GimpPalette *colormap_palette = NULL;
|
||||||
GimpImageBaseType base_type = GIMP_RGB;
|
GimpImageBaseType base_type = GIMP_RGB;
|
||||||
GimpRGB transformed_color;
|
GimpRGB transformed_color;
|
||||||
|
@ -896,14 +897,14 @@ gimp_fg_bg_editor_draw_color_frame (GimpFgBgEditor *editor,
|
||||||
{
|
{
|
||||||
gimp_color_transform_process_pixels (editor->transform,
|
gimp_color_transform_process_pixels (editor->transform,
|
||||||
babl_format ("R'G'B'A double"),
|
babl_format ("R'G'B'A double"),
|
||||||
color,
|
rgb,
|
||||||
babl_format ("R'G'B'A double"),
|
babl_format ("R'G'B'A double"),
|
||||||
&transformed_color,
|
&transformed_color,
|
||||||
1);
|
1);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
transformed_color = *color;
|
transformed_color = *rgb;
|
||||||
}
|
}
|
||||||
|
|
||||||
cairo_save (cr);
|
cairo_save (cr);
|
||||||
|
@ -913,19 +914,22 @@ gimp_fg_bg_editor_draw_color_frame (GimpFgBgEditor *editor,
|
||||||
cairo_rectangle (cr, x, y, width, height);
|
cairo_rectangle (cr, x, y, width, height);
|
||||||
cairo_fill (cr);
|
cairo_fill (cr);
|
||||||
|
|
||||||
|
color = gegl_color_new ("black");
|
||||||
|
gegl_color_set_rgba_with_space (color, rgb->r, rgb->g, rgb->b, rgb->a, NULL);
|
||||||
|
|
||||||
if (editor->color_config &&
|
if (editor->color_config &&
|
||||||
/* Common out-of-gamut case */
|
/* Common out-of-gamut case */
|
||||||
((color->r < 0.0 || color->r > 1.0 ||
|
((rgb->r < 0.0 || rgb->r > 1.0 ||
|
||||||
color->g < 0.0 || color->g > 1.0 ||
|
rgb->g < 0.0 || rgb->g > 1.0 ||
|
||||||
color->b < 0.0 || color->b > 1.0) ||
|
rgb->b < 0.0 || rgb->b > 1.0) ||
|
||||||
/* Indexed images */
|
/* Indexed images */
|
||||||
(colormap_palette &&
|
(colormap_palette &&
|
||||||
! gimp_palette_find_entry (colormap_palette, color, NULL)) ||
|
! gimp_palette_find_entry (colormap_palette, color, NULL)) ||
|
||||||
/* Grayscale images */
|
/* Grayscale images */
|
||||||
(base_type == GIMP_GRAY &&
|
(base_type == GIMP_GRAY &&
|
||||||
(ABS (color->r - color->g) > CHANNEL_EPSILON ||
|
(ABS (rgb->r - rgb->g) > CHANNEL_EPSILON ||
|
||||||
ABS (color->r - color->b) > CHANNEL_EPSILON ||
|
ABS (rgb->r - rgb->b) > CHANNEL_EPSILON ||
|
||||||
ABS (color->g - color->b) > CHANNEL_EPSILON))))
|
ABS (rgb->g - rgb->b) > CHANNEL_EPSILON))))
|
||||||
{
|
{
|
||||||
gint corner_x = x + 0.5 * (1.0 - corner_dx) * width;
|
gint corner_x = x + 0.5 * (1.0 - corner_dx) * width;
|
||||||
gint corner_y = y + 0.5 * (1.0 - corner_dy) * height;
|
gint corner_y = y + 0.5 * (1.0 - corner_dy) * height;
|
||||||
|
@ -954,4 +958,6 @@ gimp_fg_bg_editor_draw_color_frame (GimpFgBgEditor *editor,
|
||||||
cairo_stroke (cr);
|
cairo_stroke (cr);
|
||||||
|
|
||||||
cairo_restore (cr);
|
cairo_restore (cr);
|
||||||
|
|
||||||
|
g_object_unref (color);
|
||||||
}
|
}
|
||||||
|
|
|
@ -524,16 +524,17 @@ gimp_palette_editor_edit_color (GimpPaletteEditor *editor)
|
||||||
|
|
||||||
void
|
void
|
||||||
gimp_palette_editor_pick_color (GimpPaletteEditor *editor,
|
gimp_palette_editor_pick_color (GimpPaletteEditor *editor,
|
||||||
const GimpRGB *color,
|
GeglColor *color,
|
||||||
GimpColorPickState pick_state)
|
GimpColorPickState pick_state)
|
||||||
{
|
{
|
||||||
g_return_if_fail (GIMP_IS_PALETTE_EDITOR (editor));
|
g_return_if_fail (GIMP_IS_PALETTE_EDITOR (editor));
|
||||||
g_return_if_fail (color != NULL);
|
g_return_if_fail (GEGL_IS_COLOR (color));
|
||||||
|
|
||||||
if (GIMP_DATA_EDITOR (editor)->data_editable)
|
if (GIMP_DATA_EDITOR (editor)->data_editable)
|
||||||
{
|
{
|
||||||
GimpPaletteEntry *entry;
|
GimpPaletteEntry *entry;
|
||||||
GimpData *data;
|
GimpData *data;
|
||||||
|
GimpRGB rgb;
|
||||||
gint index = -1;
|
gint index = -1;
|
||||||
|
|
||||||
data = gimp_data_editor_get_data (GIMP_DATA_EDITOR (editor));
|
data = gimp_data_editor_get_data (GIMP_DATA_EDITOR (editor));
|
||||||
|
@ -541,6 +542,7 @@ gimp_palette_editor_pick_color (GimpPaletteEditor *editor,
|
||||||
index = gimp_palette_get_entry_position (GIMP_PALETTE (data),
|
index = gimp_palette_get_entry_position (GIMP_PALETTE (data),
|
||||||
editor->color);
|
editor->color);
|
||||||
|
|
||||||
|
gegl_color_get_rgba_with_space (color, &rgb.r, &rgb.g, &rgb.b, &rgb.a, NULL);
|
||||||
switch (pick_state)
|
switch (pick_state)
|
||||||
{
|
{
|
||||||
case GIMP_COLOR_PICK_STATE_START:
|
case GIMP_COLOR_PICK_STATE_START:
|
||||||
|
@ -548,7 +550,7 @@ gimp_palette_editor_pick_color (GimpPaletteEditor *editor,
|
||||||
index += 1;
|
index += 1;
|
||||||
|
|
||||||
entry = gimp_palette_add_entry (GIMP_PALETTE (data), index,
|
entry = gimp_palette_add_entry (GIMP_PALETTE (data), index,
|
||||||
NULL, color);
|
NULL, &rgb);
|
||||||
gimp_palette_view_select_entry (GIMP_PALETTE_VIEW (editor->view),
|
gimp_palette_view_select_entry (GIMP_PALETTE_VIEW (editor->view),
|
||||||
entry);
|
entry);
|
||||||
break;
|
break;
|
||||||
|
@ -556,7 +558,7 @@ gimp_palette_editor_pick_color (GimpPaletteEditor *editor,
|
||||||
case GIMP_COLOR_PICK_STATE_UPDATE:
|
case GIMP_COLOR_PICK_STATE_UPDATE:
|
||||||
case GIMP_COLOR_PICK_STATE_END:
|
case GIMP_COLOR_PICK_STATE_END:
|
||||||
gimp_palette_set_entry_color (GIMP_PALETTE (data),
|
gimp_palette_set_entry_color (GIMP_PALETTE (data),
|
||||||
index, color, FALSE);
|
index, &rgb, FALSE);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -635,12 +637,12 @@ gimp_palette_editor_zoom (GimpPaletteEditor *editor,
|
||||||
|
|
||||||
gint
|
gint
|
||||||
gimp_palette_editor_get_index (GimpPaletteEditor *editor,
|
gimp_palette_editor_get_index (GimpPaletteEditor *editor,
|
||||||
const GimpRGB *search)
|
GeglColor *search)
|
||||||
{
|
{
|
||||||
GimpPalette *palette;
|
GimpPalette *palette;
|
||||||
|
|
||||||
g_return_val_if_fail (GIMP_IS_PALETTE_EDITOR (editor), -1);
|
g_return_val_if_fail (GIMP_IS_PALETTE_EDITOR (editor), -1);
|
||||||
g_return_val_if_fail (search != NULL, -1);
|
g_return_val_if_fail (GEGL_IS_COLOR (search), -1);
|
||||||
|
|
||||||
palette = GIMP_PALETTE (GIMP_DATA_EDITOR (editor)->data);
|
palette = GIMP_PALETTE (GIMP_DATA_EDITOR (editor)->data);
|
||||||
|
|
||||||
|
|
|
@ -65,13 +65,13 @@ GtkWidget * gimp_palette_editor_new (GimpContext *context,
|
||||||
|
|
||||||
void gimp_palette_editor_edit_color (GimpPaletteEditor *editor);
|
void gimp_palette_editor_edit_color (GimpPaletteEditor *editor);
|
||||||
void gimp_palette_editor_pick_color (GimpPaletteEditor *editor,
|
void gimp_palette_editor_pick_color (GimpPaletteEditor *editor,
|
||||||
const GimpRGB *color,
|
GeglColor *color,
|
||||||
GimpColorPickState pick_state);
|
GimpColorPickState pick_state);
|
||||||
void gimp_palette_editor_zoom (GimpPaletteEditor *editor,
|
void gimp_palette_editor_zoom (GimpPaletteEditor *editor,
|
||||||
GimpZoomType zoom_type);
|
GimpZoomType zoom_type);
|
||||||
|
|
||||||
gint gimp_palette_editor_get_index (GimpPaletteEditor *editor,
|
gint gimp_palette_editor_get_index (GimpPaletteEditor *editor,
|
||||||
const GimpRGB *search);
|
GeglColor *search);
|
||||||
gboolean gimp_palette_editor_set_index (GimpPaletteEditor *editor,
|
gboolean gimp_palette_editor_set_index (GimpPaletteEditor *editor,
|
||||||
gint index,
|
gint index,
|
||||||
GimpRGB *color);
|
GimpRGB *color);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue