app, libgimp, pdb, plug-ins: getting rid of some GimpRGB usage.

This is a first commit to really getting rid of GimpRGB within core and
PDB/plug-in code. This will make color conversion reliability a lot better as
GeglColor will handle conversions for us. The goal is that we should keep origin
color space (for instance when picking colors in a GimpPickable, or when storing
in the FG/BG colors or in paletters) until the last second and convert at use
only.
It's still very much work-in-progress.
This commit is contained in:
Jehan 2023-11-12 17:56:32 +01:00
parent 75efbf77d3
commit ecf4cfb3c5
24 changed files with 122 additions and 91 deletions

View file

@ -542,7 +542,7 @@ void
gimp_channel_select_by_color (GimpChannel *channel, gimp_channel_select_by_color (GimpChannel *channel,
GList *drawables, GList *drawables,
gboolean sample_merged, gboolean sample_merged,
const GimpRGB *color, GeglColor *color,
gfloat threshold, gfloat threshold,
gboolean select_transparent, gboolean select_transparent,
GimpSelectCriterion select_criterion, GimpSelectCriterion select_criterion,

View file

@ -139,7 +139,7 @@ void gimp_channel_select_fuzzy (GimpChannel *channel,
void gimp_channel_select_by_color (GimpChannel *channel, void gimp_channel_select_by_color (GimpChannel *channel,
GList *drawables, GList *drawables,
gboolean sample_merged, gboolean sample_merged,
const GimpRGB *color, GeglColor *color,
gfloat threshold, gfloat threshold,
gboolean select_transparent, gboolean select_transparent,
GimpSelectCriterion select_criterion, GimpSelectCriterion select_criterion,

View file

@ -52,7 +52,7 @@ gimp_image_pick_color (GimpImage *image,
gdouble average_radius, gdouble average_radius,
const Babl **sample_format, const Babl **sample_format,
gpointer pixel, gpointer pixel,
GimpRGB *color) GeglColor **color)
{ {
GimpImage *pick_image = NULL; GimpImage *pick_image = NULL;
GimpPickable *pickable; GimpPickable *pickable;
@ -60,6 +60,7 @@ gimp_image_pick_color (GimpImage *image,
gboolean result; gboolean result;
g_return_val_if_fail (GIMP_IS_IMAGE (image), FALSE); g_return_val_if_fail (GIMP_IS_IMAGE (image), FALSE);
g_return_val_if_fail (color != NULL && GEGL_IS_COLOR (*color), FALSE);
for (iter = drawables; iter; iter = iter->next) for (iter = drawables; iter; iter = iter->next)
{ {
@ -177,7 +178,7 @@ gimp_image_pick_color (GimpImage *image,
} }
if (! result || sample_average) if (! result || sample_average)
gimp_pickable_pixel_to_rgb (pickable, format, sample, color); gegl_color_set_pixel (*color, format, sample);
result = TRUE; result = TRUE;
} }

View file

@ -29,7 +29,7 @@ gboolean gimp_image_pick_color (GimpImage *image,
gdouble average_radius, gdouble average_radius,
const Babl **sample_format, const Babl **sample_format,
gpointer pixel, gpointer pixel,
GimpRGB *color); GeglColor **color);
#endif /* __GIMP_IMAGE_PICK_COLOR_H__ */ #endif /* __GIMP_IMAGE_PICK_COLOR_H__ */

View file

@ -194,7 +194,7 @@ gimp_pickable_contiguous_region_by_color (GimpPickable *pickable,
gfloat threshold, gfloat threshold,
gboolean select_transparent, gboolean select_transparent,
GimpSelectCriterion select_criterion, GimpSelectCriterion select_criterion,
const GimpRGB *color) GeglColor *color)
{ {
/* Scan over the pickable's active layer, finding pixels within the /* Scan over the pickable's active layer, finding pixels within the
* specified threshold from the given R, G, & B values. If * specified threshold from the given R, G, & B values. If
@ -210,7 +210,7 @@ gimp_pickable_contiguous_region_by_color (GimpPickable *pickable,
gfloat start_col[MAX_CHANNELS]; gfloat start_col[MAX_CHANNELS];
g_return_val_if_fail (GIMP_IS_PICKABLE (pickable), NULL); g_return_val_if_fail (GIMP_IS_PICKABLE (pickable), NULL);
g_return_val_if_fail (color != NULL, NULL); g_return_val_if_fail (GEGL_IS_COLOR (color), NULL);
/* increase the threshold by EPSILON, to allow for conversion errors, /* increase the threshold by EPSILON, to allow for conversion errors,
* especially when threshold == 0 (see issue #1554.) we need to do this * especially when threshold == 0 (see issue #1554.) we need to do this
@ -227,7 +227,7 @@ gimp_pickable_contiguous_region_by_color (GimpPickable *pickable,
format = choose_format (src_buffer, select_criterion, format = choose_format (src_buffer, select_criterion,
&n_components, &has_alpha); &n_components, &has_alpha);
gimp_rgba_get_pixel (color, format, start_col); gegl_color_get_pixel (color, format, start_col);
if (has_alpha) if (has_alpha)
{ {

View file

@ -33,7 +33,7 @@ GeglBuffer * gimp_pickable_contiguous_region_by_color (GimpPickabl
gfloat threshold, gfloat threshold,
gboolean select_transparent, gboolean select_transparent,
GimpSelectCriterion select_criterion, GimpSelectCriterion select_criterion,
const GimpRGB *color); GeglColor *color);
GeglBuffer * gimp_pickable_contiguous_region_by_line_art (GimpPickable *pickable, GeglBuffer * gimp_pickable_contiguous_region_by_line_art (GimpPickable *pickable,
GimpLineArt *line_art, GimpLineArt *line_art,

View file

@ -251,23 +251,23 @@ gimp_pickable_get_pixel_average (GimpPickable *pickable,
memset (pixel, 0, babl_format_get_bytes_per_pixel (format)); memset (pixel, 0, babl_format_get_bytes_per_pixel (format));
} }
gboolean GeglColor *
gimp_pickable_get_color_at (GimpPickable *pickable, gimp_pickable_get_color_at (GimpPickable *pickable,
gint x, gint x,
gint y, gint y)
GimpRGB *color)
{ {
gdouble pixel[4]; GeglColor *color = NULL;
gdouble pixel[4];
g_return_val_if_fail (GIMP_IS_PICKABLE (pickable), FALSE); g_return_val_if_fail (GIMP_IS_PICKABLE (pickable), FALSE);
g_return_val_if_fail (color != NULL, FALSE);
if (! gimp_pickable_get_pixel_at (pickable, x, y, NULL, pixel)) if (gimp_pickable_get_pixel_at (pickable, x, y, NULL, pixel))
return FALSE; {
color = gegl_color_new ("black");
gegl_color_set_pixel (color, gimp_pickable_get_format (pickable), pixel);
}
gimp_pickable_pixel_to_rgb (pickable, NULL, pixel, color); return color;
return TRUE;
} }
gdouble gdouble
@ -287,6 +287,9 @@ gimp_pickable_get_opacity_at (GimpPickable *pickable,
return GIMP_OPACITY_TRANSPARENT; return GIMP_OPACITY_TRANSPARENT;
} }
/* TODO: this will have to be removed eventually and replaced with
* gegl_color_set_pixel(). We should not need GimpRGB anymore!
*/
void void
gimp_pickable_pixel_to_rgb (GimpPickable *pickable, gimp_pickable_pixel_to_rgb (GimpPickable *pickable,
const Babl *format, const Babl *format,
@ -363,13 +366,13 @@ gimp_pickable_pick_color (GimpPickable *pickable,
gboolean sample_average, gboolean sample_average,
gdouble average_radius, gdouble average_radius,
gpointer pixel, gpointer pixel,
GimpRGB *color) GeglColor **color)
{ {
const Babl *format; const Babl *format;
gdouble sample[4]; gdouble sample[4];
g_return_val_if_fail (GIMP_IS_PICKABLE (pickable), FALSE); g_return_val_if_fail (GIMP_IS_PICKABLE (pickable), FALSE);
g_return_val_if_fail (color != NULL, FALSE); g_return_val_if_fail (color != NULL && GEGL_IS_COLOR (*color), FALSE);
format = gimp_pickable_get_format (pickable); format = gimp_pickable_get_format (pickable);
@ -394,7 +397,7 @@ gimp_pickable_pick_color (GimpPickable *pickable,
format, sample); format, sample);
} }
gimp_pickable_pixel_to_rgb (pickable, format, sample, color); gegl_color_set_pixel (*color, format, sample);
return TRUE; return TRUE;
} }

View file

@ -70,10 +70,9 @@ gboolean gimp_pickable_get_pixel_at (GimpPickable *pick
gint y, gint y,
const Babl *format, const Babl *format,
gpointer pixel); gpointer pixel);
gboolean gimp_pickable_get_color_at (GimpPickable *pickable, GeglColor * gimp_pickable_get_color_at (GimpPickable *pickable,
gint x, gint x,
gint y, gint y);
GimpRGB *color);
gdouble gimp_pickable_get_opacity_at (GimpPickable *pickable, gdouble gimp_pickable_get_opacity_at (GimpPickable *pickable,
gint x, gint x,
gint y); gint y);
@ -99,7 +98,7 @@ gboolean gimp_pickable_pick_color (GimpPickable *pick
gboolean sample_average, gboolean sample_average,
gdouble average_radius, gdouble average_radius,
gpointer pixel, gpointer pixel,
GimpRGB *color); GeglColor **color);
#endif /* __GIMP_PICKABLE_H__ */ #endif /* __GIMP_PICKABLE_H__ */

View file

@ -758,7 +758,7 @@ gimp_cursor_view_cursor_idle (GimpCursorView *view)
gchar buf[32]; gchar buf[32];
const Babl *sample_format; const Babl *sample_format;
gdouble pixel[4]; gdouble pixel[4];
GimpRGB color; GeglColor *color;
gdouble xres; gdouble xres;
gdouble yres; gdouble yres;
gint int_x; gint int_x;
@ -791,6 +791,7 @@ gimp_cursor_view_cursor_idle (GimpCursorView *view)
int_x = (gint) floor (x); int_x = (gint) floor (x);
int_y = (gint) floor (y); int_y = (gint) floor (y);
color = gegl_color_new ("black");
if (gimp_image_pick_color (image, NULL, if (gimp_image_pick_color (image, NULL,
int_x, int_y, int_x, int_y,
view->priv->shell->show_all, view->priv->shell->show_all,
@ -798,11 +799,15 @@ gimp_cursor_view_cursor_idle (GimpCursorView *view)
FALSE, 0.0, FALSE, 0.0,
&sample_format, pixel, &color)) &sample_format, pixel, &color))
{ {
GimpRGB rgb;
/* TODO: get rid of GimpRGB. */
gegl_color_get_rgba_with_space (color, &rgb.r, &rgb.g, &rgb.b, &rgb.a, NULL);
gimp_color_frame_set_color (GIMP_COLOR_FRAME (view->priv->color_frame_1), gimp_color_frame_set_color (GIMP_COLOR_FRAME (view->priv->color_frame_1),
FALSE, sample_format, pixel, &color, FALSE, sample_format, pixel, &rgb,
int_x, int_y); int_x, int_y);
gimp_color_frame_set_color (GIMP_COLOR_FRAME (view->priv->color_frame_2), gimp_color_frame_set_color (GIMP_COLOR_FRAME (view->priv->color_frame_2),
FALSE, sample_format, pixel, &color, FALSE, sample_format, pixel, &rgb,
int_x, int_y); int_x, int_y);
} }
else else
@ -817,6 +822,7 @@ gimp_cursor_view_cursor_idle (GimpCursorView *view)
view->priv->cursor_unit); view->priv->cursor_unit);
g_clear_object (&view->priv->cursor_image); g_clear_object (&view->priv->cursor_image);
g_object_unref (color);
} }
else else
{ {

View file

@ -21,14 +21,11 @@
#include "stamp-pdbgen.h" #include "stamp-pdbgen.h"
#include <cairo.h>
#include <gegl.h> #include <gegl.h>
#include <gdk-pixbuf/gdk-pixbuf.h> #include <gdk-pixbuf/gdk-pixbuf.h>
#include "libgimpbase/gimpbase.h" #include "libgimpbase/gimpbase.h"
#include "libgimpcolor/gimpcolor.h"
#include "libgimpmath/gimpmath.h" #include "libgimpmath/gimpmath.h"
#include "libgimpbase/gimpbase.h" #include "libgimpbase/gimpbase.h"
@ -657,7 +654,7 @@ image_pick_color_invoker (GimpProcedure *procedure,
gboolean sample_merged; gboolean sample_merged;
gboolean sample_average; gboolean sample_average;
gdouble average_radius; gdouble average_radius;
GimpRGB color = { 0.0, 0.0, 0.0, 1.0 }; GeglColor *color = NULL;
image = g_value_get_object (gimp_value_array_index (args, 0)); image = g_value_get_object (gimp_value_array_index (args, 0));
num_drawables = g_value_get_int (gimp_value_array_index (args, 1)); num_drawables = g_value_get_int (gimp_value_array_index (args, 1));
@ -711,6 +708,7 @@ image_pick_color_invoker (GimpProcedure *procedure,
if (sample_merged) if (sample_merged)
gimp_pickable_flush (GIMP_PICKABLE (image)); gimp_pickable_flush (GIMP_PICKABLE (image));
color = gegl_color_new ("black");
success = gimp_image_pick_color (image, success = gimp_image_pick_color (image,
drawable_list, drawable_list,
(gint) x, (gint) y, (gint) x, (gint) y,
@ -730,7 +728,7 @@ image_pick_color_invoker (GimpProcedure *procedure,
error ? *error : NULL); error ? *error : NULL);
if (success) if (success)
gimp_value_set_rgb (gimp_value_array_index (return_vals, 1), &color); g_value_take_object (gimp_value_array_index (return_vals, 1), color);
return return_vals; return return_vals;
} }
@ -3576,12 +3574,11 @@ register_image_procs (GimpPDB *pdb)
0, G_MAXDOUBLE, 0, 0, G_MAXDOUBLE, 0,
GIMP_PARAM_READWRITE | GIMP_PARAM_NO_VALIDATE)); GIMP_PARAM_READWRITE | GIMP_PARAM_NO_VALIDATE));
gimp_procedure_add_return_value (procedure, gimp_procedure_add_return_value (procedure,
gimp_param_spec_rgb ("color", gegl_param_spec_color ("color",
"color", "color",
"The return color", "The return color",
TRUE, NULL,
NULL, GIMP_PARAM_READWRITE));
GIMP_PARAM_READWRITE));
gimp_pdb_register_procedure (pdb, procedure); gimp_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure); g_object_unref (procedure);

View file

@ -21,14 +21,11 @@
#include "stamp-pdbgen.h" #include "stamp-pdbgen.h"
#include <cairo.h>
#include <gegl.h> #include <gegl.h>
#include <gdk-pixbuf/gdk-pixbuf.h> #include <gdk-pixbuf/gdk-pixbuf.h>
#include "libgimpbase/gimpbase.h" #include "libgimpbase/gimpbase.h"
#include "libgimpcolor/gimpcolor.h"
#include "libgimpbase/gimpbase.h" #include "libgimpbase/gimpbase.h"
@ -61,12 +58,12 @@ image_select_color_invoker (GimpProcedure *procedure,
GimpImage *image; GimpImage *image;
gint operation; gint operation;
GimpDrawable *drawable; GimpDrawable *drawable;
GimpRGB color; GeglColor *color;
image = g_value_get_object (gimp_value_array_index (args, 0)); image = g_value_get_object (gimp_value_array_index (args, 0));
operation = g_value_get_enum (gimp_value_array_index (args, 1)); operation = g_value_get_enum (gimp_value_array_index (args, 1));
drawable = g_value_get_object (gimp_value_array_index (args, 2)); drawable = g_value_get_object (gimp_value_array_index (args, 2));
gimp_value_get_rgb (gimp_value_array_index (args, 3), &color); color = g_value_get_object (gimp_value_array_index (args, 3));
if (success) if (success)
{ {
@ -78,7 +75,7 @@ image_select_color_invoker (GimpProcedure *procedure,
GList *drawables = g_list_prepend (NULL, drawable); GList *drawables = g_list_prepend (NULL, drawable);
gimp_channel_select_by_color (gimp_image_get_mask (image), drawables, gimp_channel_select_by_color (gimp_image_get_mask (image), drawables,
pdb_context->sample_merged, pdb_context->sample_merged,
&color, color,
pdb_context->sample_threshold, pdb_context->sample_threshold,
pdb_context->sample_transparent, pdb_context->sample_transparent,
pdb_context->sample_criterion, pdb_context->sample_criterion,
@ -398,12 +395,11 @@ register_image_select_procs (GimpPDB *pdb)
FALSE, FALSE,
GIMP_PARAM_READWRITE)); GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure, gimp_procedure_add_argument (procedure,
gimp_param_spec_rgb ("color", gegl_param_spec_color ("color",
"color", "color",
"The color to select", "The color to select",
FALSE, NULL,
NULL, GIMP_PARAM_READWRITE));
GIMP_PARAM_READWRITE));
gimp_pdb_register_procedure (pdb, procedure); gimp_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure); g_object_unref (procedure);

View file

@ -106,7 +106,7 @@ gimp_by_color_select_tool_get_mask (GimpRegionSelectTool *region_select,
GList *drawables = gimp_image_get_selected_drawables (image); GList *drawables = gimp_image_get_selected_drawables (image);
GimpPickable *pickable; GimpPickable *pickable;
GeglBuffer *mask = NULL; GeglBuffer *mask = NULL;
GimpRGB srgb; GeglColor *color;
gint x, y; gint x, y;
x = region_select->x; x = region_select->x;
@ -142,18 +142,15 @@ gimp_by_color_select_tool_get_mask (GimpRegionSelectTool *region_select,
g_list_free (drawables); g_list_free (drawables);
gimp_pickable_flush (pickable); gimp_pickable_flush (pickable);
if (gimp_pickable_get_color_at (pickable, x, y, &srgb)) if ((color = gimp_pickable_get_color_at (pickable, x, y)) != NULL)
{ {
GimpRGB color;
gimp_pickable_srgb_to_image_color (pickable, &srgb, &color);
mask = gimp_pickable_contiguous_region_by_color (pickable, mask = gimp_pickable_contiguous_region_by_color (pickable,
sel_options->antialias, sel_options->antialias,
options->threshold / 255.0, options->threshold / 255.0,
options->select_transparent, options->select_transparent,
options->select_criterion, options->select_criterion,
&color); color);
g_object_unref (color);
} }
if (select_image) if (select_image)

View file

@ -106,7 +106,7 @@ static gboolean gimp_color_tool_real_pick (GimpColorTool *color_tool,
GimpDisplay *display, GimpDisplay *display,
const Babl **sample_format, const Babl **sample_format,
gpointer pixel, gpointer pixel,
GimpRGB *color); GeglColor **color);
static void gimp_color_tool_real_picked (GimpColorTool *color_tool, static void gimp_color_tool_real_picked (GimpColorTool *color_tool,
const GimpCoords *coords, const GimpCoords *coords,
GimpDisplay *display, GimpDisplay *display,
@ -458,13 +458,14 @@ gimp_color_tool_real_pick (GimpColorTool *color_tool,
GimpDisplay *display, GimpDisplay *display,
const Babl **sample_format, const Babl **sample_format,
gpointer pixel, gpointer pixel,
GimpRGB *color) GeglColor **color)
{ {
GimpDisplayShell *shell = gimp_display_get_shell (display); GimpDisplayShell *shell = gimp_display_get_shell (display);
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);
g_return_val_if_fail (drawables != NULL, FALSE); g_return_val_if_fail (drawables != NULL, FALSE);
g_return_val_if_fail (color != NULL && GEGL_IS_COLOR (*color), FALSE);
return gimp_image_pick_color (image, drawables, return gimp_image_pick_color (image, drawables,
coords->x, coords->y, coords->x, coords->y,
@ -628,17 +629,24 @@ gimp_color_tool_pick (GimpColorTool *tool,
GimpColorToolClass *klass; GimpColorToolClass *klass;
const Babl *sample_format; const Babl *sample_format;
gdouble pixel[4]; gdouble pixel[4];
GimpRGB color; GeglColor *color;
klass = GIMP_COLOR_TOOL_GET_CLASS (tool); klass = GIMP_COLOR_TOOL_GET_CLASS (tool);
color = gegl_color_new ("black");
if (klass->pick && if (klass->pick &&
klass->pick (tool, coords, display, &sample_format, pixel, &color)) klass->pick (tool, coords, display, &sample_format, pixel, &color))
{ {
GimpRGB rgb;
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, g_signal_emit (tool, gimp_color_tool_signals[PICKED], 0,
coords, display, pick_state, coords, display, pick_state,
sample_format, pixel, &color); sample_format, pixel, &rgb);
} }
g_object_unref (color);
} }

View file

@ -63,7 +63,7 @@ struct _GimpColorToolClass
GimpDisplay *display, GimpDisplay *display,
const Babl **sample_format, const Babl **sample_format,
gpointer pixel, gpointer pixel,
GimpRGB *color); GeglColor **color);
/* signals */ /* signals */
void (* picked) (GimpColorTool *tool, void (* picked) (GimpColorTool *tool,

View file

@ -137,7 +137,7 @@ static gboolean gimp_filter_tool_pick_color (GimpColorTool *color_too
GimpDisplay *display, GimpDisplay *display,
const Babl **sample_format, const Babl **sample_format,
gpointer pixel, gpointer pixel,
GimpRGB *color); GeglColor **color);
static void gimp_filter_tool_color_picked (GimpColorTool *color_tool, static void gimp_filter_tool_color_picked (GimpColorTool *color_tool,
const GimpCoords *coords, const GimpCoords *coords,
GimpDisplay *display, GimpDisplay *display,
@ -828,13 +828,15 @@ gimp_filter_tool_pick_color (GimpColorTool *color_tool,
GimpDisplay *display, GimpDisplay *display,
const Babl **sample_format, const Babl **sample_format,
gpointer pixel, gpointer pixel,
GimpRGB *color) GeglColor **color)
{ {
GimpTool *tool = GIMP_TOOL (color_tool); GimpTool *tool = GIMP_TOOL (color_tool);
GimpFilterTool *filter_tool = GIMP_FILTER_TOOL (color_tool); GimpFilterTool *filter_tool = GIMP_FILTER_TOOL (color_tool);
gboolean picked; gboolean picked;
g_return_val_if_fail (g_list_length (tool->drawables) == 1, FALSE); g_return_val_if_fail (g_list_length (tool->drawables) == 1, FALSE);
g_return_val_if_fail (color != NULL && GEGL_IS_COLOR (*color), FALSE);
g_return_val_if_fail (sample_format != NULL, FALSE);
picked = GIMP_COLOR_TOOL_CLASS (parent_class)->pick (color_tool, coords, picked = GIMP_COLOR_TOOL_CLASS (parent_class)->pick (color_tool, coords,
display, sample_format, display, sample_format,
@ -842,10 +844,7 @@ gimp_filter_tool_pick_color (GimpColorTool *color_tool,
if (! picked && filter_tool->pick_abyss) if (! picked && filter_tool->pick_abyss)
{ {
color->r = 0.0; gegl_color_set_rgba_with_space (*color, 0.0, 0.0, 0.0, 0.0, *sample_format);
color->g = 0.0;
color->b = 0.0;
color->a = 0.0;
picked = TRUE; picked = TRUE;
} }

View file

@ -553,7 +553,7 @@ gimp_sample_point_editor_update (GimpSamplePointEditor *editor)
GimpSamplePoint *sample_point = list->data; GimpSamplePoint *sample_point = list->data;
const Babl *format; const Babl *format;
gdouble pixel[4]; gdouble pixel[4];
GimpRGB color; GeglColor *color;
GimpColorPickMode pick_mode; GimpColorPickMode pick_mode;
gint x; gint x;
gint y; gint y;
@ -563,6 +563,7 @@ gimp_sample_point_editor_update (GimpSamplePointEditor *editor)
gimp_sample_point_get_position (sample_point, &x, &y); gimp_sample_point_get_position (sample_point, &x, &y);
color = gegl_color_new ("black");
if (gimp_image_pick_color (image_editor->image, NULL, if (gimp_image_pick_color (image_editor->image, NULL,
x, y, x, y,
FALSE, FALSE,
@ -572,8 +573,12 @@ gimp_sample_point_editor_update (GimpSamplePointEditor *editor)
pixel, pixel,
&color)) &color))
{ {
GimpRGB rgb;
/* TODO: use GeglColor. */
gegl_color_get_rgba_with_space (color, &rgb.r, &rgb.g, &rgb.b, &rgb.a, NULL);
gimp_color_frame_set_color (color_frame, FALSE, gimp_color_frame_set_color (color_frame, FALSE,
format, pixel, &color, format, pixel, &rgb,
x, y); x, y);
} }
else else
@ -584,6 +589,8 @@ gimp_sample_point_editor_update (GimpSamplePointEditor *editor)
pick_mode = gimp_sample_point_get_pick_mode (sample_point); pick_mode = gimp_sample_point_get_pick_mode (sample_point);
gimp_color_frame_set_mode (color_frame, pick_mode); gimp_color_frame_set_mode (color_frame, pick_mode);
g_object_unref (color);
} }
} }

View file

@ -248,7 +248,7 @@ gimp_selection_view_button_press (GtkWidget *widget,
GimpChannelOps operation; GimpChannelOps operation;
GList *drawables; GList *drawables;
gint x, y; gint x, y;
GimpRGB color; GeglColor *color;
if (! image_editor->image) if (! image_editor->image)
return TRUE; return TRUE;
@ -274,6 +274,7 @@ gimp_selection_view_button_press (GtkWidget *widget,
x = gimp_image_get_width (image_editor->image) * bevent->x / renderer->width; x = gimp_image_get_width (image_editor->image) * bevent->x / renderer->width;
y = gimp_image_get_height (image_editor->image) * bevent->y / renderer->height; y = gimp_image_get_height (image_editor->image) * bevent->y / renderer->height;
color = gegl_color_new ("black");
if (gimp_image_pick_color (image_editor->image, drawables, x, y, if (gimp_image_pick_color (image_editor->image, drawables, x, y,
FALSE, options->sample_merged, FALSE, options->sample_merged,
FALSE, 0.0, FALSE, 0.0,
@ -283,7 +284,7 @@ gimp_selection_view_button_press (GtkWidget *widget,
gimp_channel_select_by_color (gimp_image_get_mask (image_editor->image), gimp_channel_select_by_color (gimp_image_get_mask (image_editor->image),
drawables, drawables,
options->sample_merged, options->sample_merged,
&color, color,
options->threshold / 255.0, options->threshold / 255.0,
options->select_transparent, options->select_transparent,
options->select_criterion, options->select_criterion,
@ -294,7 +295,9 @@ gimp_selection_view_button_press (GtkWidget *widget,
sel_options->feather_radius); sel_options->feather_radius);
gimp_image_flush (image_editor->image); gimp_image_flush (image_editor->image);
} }
g_list_free (drawables); g_list_free (drawables);
g_object_unref (color);
return TRUE; return TRUE;
} }
@ -303,7 +306,8 @@ static void
gimp_selection_editor_drop_color (GtkWidget *widget, gimp_selection_editor_drop_color (GtkWidget *widget,
gint x, gint x,
gint y, gint y,
const GimpRGB *color, /* TODO: should drop a GeglColor */
const GimpRGB *rgb,
gpointer data) gpointer data)
{ {
GimpImageEditor *editor = GIMP_IMAGE_EDITOR (data); GimpImageEditor *editor = GIMP_IMAGE_EDITOR (data);
@ -311,6 +315,7 @@ gimp_selection_editor_drop_color (GtkWidget *widget,
GimpSelectionOptions *sel_options; GimpSelectionOptions *sel_options;
GimpRegionSelectOptions *options; GimpRegionSelectOptions *options;
GList *drawables; GList *drawables;
GeglColor *color;
if (! editor->image) if (! editor->image)
return; return;
@ -328,6 +333,8 @@ gimp_selection_editor_drop_color (GtkWidget *widget,
if (! drawables) if (! drawables)
return; return;
color = gegl_color_new ("black");
gegl_color_set_rgba_with_space (color, rgb->r, rgb->g, rgb->b, rgb->a, NULL);
gimp_channel_select_by_color (gimp_image_get_mask (editor->image), gimp_channel_select_by_color (gimp_image_get_mask (editor->image),
drawables, drawables,
options->sample_merged, options->sample_merged,
@ -342,6 +349,7 @@ gimp_selection_editor_drop_color (GtkWidget *widget,
sel_options->feather_radius); sel_options->feather_radius);
gimp_image_flush (editor->image); gimp_image_flush (editor->image);
g_list_free (drawables); g_list_free (drawables);
g_object_unref (color);
} }
static void static void

View file

@ -723,7 +723,7 @@ gimp_image_floating_sel_attached_to (GimpImage *image)
* @sample_merged: Use the composite image, not the drawables. * @sample_merged: Use the composite image, not the drawables.
* @sample_average: Average the color of all the pixels in a specified radius. * @sample_average: Average the color of all the pixels in a specified radius.
* @average_radius: The radius of pixels to average. * @average_radius: The radius of pixels to average.
* @color: (out caller-allocates): The return color. * @color: (out) (transfer full): The return color.
* *
* Determine the color at the given coordinates * Determine the color at the given coordinates
* *
@ -754,7 +754,7 @@ gimp_image_pick_color (GimpImage *image,
gboolean sample_merged, gboolean sample_merged,
gboolean sample_average, gboolean sample_average,
gdouble average_radius, gdouble average_radius,
GimpRGB *color) GeglColor **color)
{ {
GimpValueArray *args; GimpValueArray *args;
GimpValueArray *return_vals; GimpValueArray *return_vals;
@ -777,10 +777,12 @@ gimp_image_pick_color (GimpImage *image,
args); args);
gimp_value_array_unref (args); gimp_value_array_unref (args);
*color = NULL;
success = GIMP_VALUES_GET_ENUM (return_vals, 0) == GIMP_PDB_SUCCESS; success = GIMP_VALUES_GET_ENUM (return_vals, 0) == GIMP_PDB_SUCCESS;
if (success) if (success)
GIMP_VALUES_GET_RGB (return_vals, 1, &*color); *color = g_value_dup_object (gimp_value_array_index (return_vals, 1));
gimp_value_array_unref (return_vals); gimp_value_array_unref (return_vals);

View file

@ -65,7 +65,7 @@ gboolean gimp_image_pick_color (GimpImage
gboolean sample_merged, gboolean sample_merged,
gboolean sample_average, gboolean sample_average,
gdouble average_radius, gdouble average_radius,
GimpRGB *color); GeglColor **color);
GimpLayer* gimp_image_pick_correlate_layer (GimpImage *image, GimpLayer* gimp_image_pick_correlate_layer (GimpImage *image,
gint x, gint x,
gint y); gint y);

View file

@ -71,7 +71,7 @@ gboolean
gimp_image_select_color (GimpImage *image, gimp_image_select_color (GimpImage *image,
GimpChannelOps operation, GimpChannelOps operation,
GimpDrawable *drawable, GimpDrawable *drawable,
const GimpRGB *color) GeglColor *color)
{ {
GimpValueArray *args; GimpValueArray *args;
GimpValueArray *return_vals; GimpValueArray *return_vals;
@ -81,7 +81,7 @@ gimp_image_select_color (GimpImage *image,
GIMP_TYPE_IMAGE, image, GIMP_TYPE_IMAGE, image,
GIMP_TYPE_CHANNEL_OPS, operation, GIMP_TYPE_CHANNEL_OPS, operation,
GIMP_TYPE_DRAWABLE, drawable, GIMP_TYPE_DRAWABLE, drawable,
GIMP_TYPE_RGB, color, GEGL_TYPE_COLOR, color,
G_TYPE_NONE); G_TYPE_NONE);
return_vals = _gimp_pdb_run_procedure_array (gimp_get_pdb (), return_vals = _gimp_pdb_run_procedure_array (gimp_get_pdb (),

View file

@ -35,7 +35,7 @@ G_BEGIN_DECLS
gboolean gimp_image_select_color (GimpImage *image, gboolean gimp_image_select_color (GimpImage *image,
GimpChannelOps operation, GimpChannelOps operation,
GimpDrawable *drawable, GimpDrawable *drawable,
const GimpRGB *color); GeglColor *color);
gboolean gimp_image_select_contiguous_color (GimpImage *image, gboolean gimp_image_select_contiguous_color (GimpImage *image,
GimpChannelOps operation, GimpChannelOps operation,
GimpDrawable *drawable, GimpDrawable *drawable,

View file

@ -457,7 +457,7 @@ HELP
); );
@outargs = ( @outargs = (
{ name => 'color', type => 'color', has_alpha => 1, void_ret => 1, { name => 'color', type => 'geglcolor', has_alpha => 1, void_ret => 1,
desc => 'The return color' } desc => 'The return color' }
); );
@ -506,6 +506,7 @@ HELP
if (sample_merged) if (sample_merged)
gimp_pickable_flush (GIMP_PICKABLE (image)); gimp_pickable_flush (GIMP_PICKABLE (image));
color = gegl_color_new ("black");
success = gimp_image_pick_color (image, success = gimp_image_pick_color (image,
drawable_list, drawable_list,
(gint) x, (gint) y, (gint) x, (gint) y,

View file

@ -51,7 +51,7 @@ HELP
desc => 'The selection operation' }, desc => 'The selection operation' },
{ name => 'drawable', type => 'drawable', { name => 'drawable', type => 'drawable',
desc => 'The affected drawable' }, desc => 'The affected drawable' },
{ name => 'color', type => 'color', { name => 'color', type => 'geglcolor',
desc => 'The color to select' } desc => 'The color to select' }
); );
@ -66,7 +66,7 @@ HELP
GList *drawables = g_list_prepend (NULL, drawable); GList *drawables = g_list_prepend (NULL, drawable);
gimp_channel_select_by_color (gimp_image_get_mask (image), drawables, gimp_channel_select_by_color (gimp_image_get_mask (image), drawables,
pdb_context->sample_merged, pdb_context->sample_merged,
&color, color,
pdb_context->sample_threshold, pdb_context->sample_threshold,
pdb_context->sample_transparent, pdb_context->sample_transparent,
pdb_context->sample_criterion, pdb_context->sample_criterion,

View file

@ -1554,7 +1554,7 @@ drawText (GimpLayer *layer,
cairo_font_options_t *options; cairo_font_options_t *options;
gint x; gint x;
gint y; gint y;
GimpRGB color; GimpRGB rgb;
GimpUnit unit; GimpUnit unit;
gdouble size; gdouble size;
GimpTextHintStyle hinting; GimpTextHintStyle hinting;
@ -1587,13 +1587,20 @@ drawText (GimpLayer *layer,
/* When dealing with a gray/indexed image, the viewed color of the text layer /* When dealing with a gray/indexed image, the viewed color of the text layer
* can be different than the one kept in the memory */ * can be different than the one kept in the memory */
if (type == GIMP_RGBA_IMAGE) if (type == GIMP_RGBA_IMAGE)
gimp_text_layer_get_color (GIMP_TEXT_LAYER (layer), &color); {
gimp_text_layer_get_color (GIMP_TEXT_LAYER (layer), &rgb);
}
else else
gimp_image_pick_color (gimp_item_get_image (GIMP_ITEM (layer)), 1, {
(const GimpItem**) &layer, x, y, FALSE, FALSE, 0, GeglColor *color;
&color);
cairo_set_source_rgba (cr, color.r, color.g, color.b, opacity); gimp_image_pick_color (gimp_item_get_image (GIMP_ITEM (layer)), 1,
(const GimpItem**) &layer, x, y, FALSE, FALSE, 0,
&color);
gegl_color_get_rgba_with_space (color, &rgb.r, &rgb.g, &rgb.b, &rgb.a, NULL);
}
cairo_set_source_rgba (cr, rgb.r, rgb.g, rgb.b, opacity);
/* Hinting */ /* Hinting */
hinting = gimp_text_layer_get_hint_style (GIMP_TEXT_LAYER (layer)); hinting = gimp_text_layer_get_hint_style (GIMP_TEXT_LAYER (layer));