Fixed color picking (reported by jimmac on #gimp):

2002-06-20  Michael Natterer  <mitch@gimp.org>

	Fixed color picking (reported by jimmac on #gimp):

	* app/core/gimpimage-pick-color.c: set the returned color's alpha
	value to opaque if the drawable we pick from has no aplha.

	* app/tools/gimpcolorpickertool.c: ignore all values returned by
	gimp_image_pick_color() if it returns FALSE (which happens if we
	want to pick outside the drawable).
This commit is contained in:
Michael Natterer 2002-06-19 22:09:02 +00:00 committed by Michael Natterer
parent d000f5fa8c
commit 0aec31c3c6
3 changed files with 48 additions and 32 deletions

View File

@ -1,3 +1,14 @@
2002-06-20 Michael Natterer <mitch@gimp.org>
Fixed color picking (reported by jimmac on #gimp):
* app/core/gimpimage-pick-color.c: set the returned color's alpha
value to opaque if the drawable we pick from has no aplha.
* app/tools/gimpcolorpickertool.c: ignore all values returned by
gimp_image_pick_color() if it returns FALSE (which happens if we
want to pick outside the drawable).
2002-06-19 Michael Natterer <mitch@gimp.org>
Fix for #85202:

View File

@ -134,10 +134,11 @@ gimp_image_pick_color (GimpImage *gimage,
col[BLUE_PIX],
col[ALPHA_PIX]);
else
gimp_rgb_set_uchar (&rgb_color,
col[RED_PIX],
col[GREEN_PIX],
col[BLUE_PIX]);
gimp_rgba_set_uchar (&rgb_color,
col[RED_PIX],
col[GREEN_PIX],
col[BLUE_PIX],
OPAQUE_OPACITY);
g_free (col);

View File

@ -532,44 +532,48 @@ gimp_color_picker_tool_pick_color (GimpImage *gimage,
{
GimpRGB color;
gint color_index;
gboolean retval;
guchar r, g, b, a;
gboolean success;
retval = gimp_image_pick_color (gimage,
drawable,
sample_merged,
x, y,
sample_average,
average_radius,
&color,
&sample_type,
&color_index);
success = gimp_image_pick_color (gimage,
drawable,
sample_merged,
x, y,
sample_average,
average_radius,
&color,
&sample_type,
&color_index);
gimp_rgba_get_uchar (&color, &r, &g, &b, &a);
col_value[RED_PIX] = r;
col_value[GREEN_PIX] = g;
col_value[BLUE_PIX] = b;
col_value[ALPHA_PIX] = a;
col_value[4] = color_index;
if (update_active)
if (success)
{
GimpContext *user_context;
guchar r, g, b, a;
user_context = gimp_get_user_context (gimage->gimp);
gimp_rgba_get_uchar (&color, &r, &g, &b, &a);
col_value[RED_PIX] = r;
col_value[GREEN_PIX] = g;
col_value[BLUE_PIX] = b;
col_value[ALPHA_PIX] = a;
col_value[4] = color_index;
if (update_active)
{
GimpContext *user_context;
user_context = gimp_get_user_context (gimage->gimp);
#if 0
gimp_palette_editor_update_color (user_context, &color, update_state);
gimp_palette_editor_update_color (user_context, &color, update_state);
#endif
if (active_color == FOREGROUND)
gimp_context_set_foreground (user_context, &color);
else if (active_color == BACKGROUND)
gimp_context_set_background (user_context, &color);
if (active_color == FOREGROUND)
gimp_context_set_foreground (user_context, &color);
else if (active_color == BACKGROUND)
gimp_context_set_background (user_context, &color);
}
}
return retval;
return success;
}
static void