use OPAQUE_OPACITY instead of 255.
2003-06-05 Sven Neumann <sven@gimp.org> * app/core/gimpdrawable.c (gimp_drawable_get_color_at): * app/core/gimpimage-projection.c (gimp_image_projection_get_color_at): use OPAQUE_OPACITY instead of 255. * app/core/gimpimage-pick-color.[ch]: factored out code that averages over colors so it can be used from GimpImageTool. * app/tools/gimpimagemaptool.[ch]: derived from GimpColorTool and added a GimpColorTool::pick implementation. * app/tools/gimpcoloroptions.c * app/tools/gimpcolorpickeroptions.c: add the toggle for "sample_merged" in gimp_color_picker_options_gui(). * app/tools/gimpcolortool.c (gimp_color_tool_cursor_update): check if the cursor is over the active drawable or if "sample_merged" is active. * app/tools/gimplevelstool.c: simplified since all color-picking is now handled by the parent classes. Fixes bug #112668.
This commit is contained in:

committed by
Sven Neumann

parent
21b4aba939
commit
b1c437b4f8
23
ChangeLog
23
ChangeLog
@ -1,3 +1,26 @@
|
|||||||
|
2003-06-05 Sven Neumann <sven@gimp.org>
|
||||||
|
|
||||||
|
* app/core/gimpdrawable.c (gimp_drawable_get_color_at):
|
||||||
|
* app/core/gimpimage-projection.c (gimp_image_projection_get_color_at):
|
||||||
|
use OPAQUE_OPACITY instead of 255.
|
||||||
|
|
||||||
|
* app/core/gimpimage-pick-color.[ch]: factored out code that
|
||||||
|
averages over colors so it can be used from GimpImageTool.
|
||||||
|
|
||||||
|
* app/tools/gimpimagemaptool.[ch]: derived from GimpColorTool and
|
||||||
|
added a GimpColorTool::pick implementation.
|
||||||
|
|
||||||
|
* app/tools/gimpcoloroptions.c
|
||||||
|
* app/tools/gimpcolorpickeroptions.c: add the toggle for
|
||||||
|
"sample_merged" in gimp_color_picker_options_gui().
|
||||||
|
|
||||||
|
* app/tools/gimpcolortool.c (gimp_color_tool_cursor_update): check
|
||||||
|
if the cursor is over the active drawable or if "sample_merged" is
|
||||||
|
active.
|
||||||
|
|
||||||
|
* app/tools/gimplevelstool.c: simplified since all color-picking is
|
||||||
|
now handled by the parent classes. Fixes bug #112668.
|
||||||
|
|
||||||
2003-06-05 Sven Neumann <sven@gimp.org>
|
2003-06-05 Sven Neumann <sven@gimp.org>
|
||||||
|
|
||||||
* app/tools/gimpcoloroptions.c: changed the default radius.
|
* app/tools/gimpcoloroptions.c: changed the default radius.
|
||||||
|
@ -1005,7 +1005,7 @@ gimp_drawable_get_color_at (GimpDrawable *drawable,
|
|||||||
if (GIMP_IMAGE_TYPE_HAS_ALPHA (gimp_drawable_type (drawable)))
|
if (GIMP_IMAGE_TYPE_HAS_ALPHA (gimp_drawable_type (drawable)))
|
||||||
dest[3] = src[gimp_drawable_bytes (drawable) - 1];
|
dest[3] = src[gimp_drawable_bytes (drawable) - 1];
|
||||||
else
|
else
|
||||||
dest[3] = 255;
|
dest[3] = OPAQUE_OPACITY;
|
||||||
|
|
||||||
if (gimp_drawable_is_indexed (drawable))
|
if (gimp_drawable_is_indexed (drawable))
|
||||||
dest[4] = src[0];
|
dest[4] = src[0];
|
||||||
|
@ -26,34 +26,26 @@
|
|||||||
|
|
||||||
#include "core/gimpdrawable.h"
|
#include "core/gimpdrawable.h"
|
||||||
#include "core/gimpimage.h"
|
#include "core/gimpimage.h"
|
||||||
|
#include "core/gimpimage-pick-color.h"
|
||||||
#include "core/gimpimage-projection.h"
|
#include "core/gimpimage-projection.h"
|
||||||
|
|
||||||
|
|
||||||
typedef guchar * (* GetColorFunc) (GimpObject *object,
|
|
||||||
gint x,
|
|
||||||
gint y);
|
|
||||||
|
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
gimp_image_pick_color (GimpImage *gimage,
|
gimp_image_pick_color (GimpImage *gimage,
|
||||||
GimpDrawable *drawable,
|
GimpDrawable *drawable,
|
||||||
gboolean sample_merged,
|
|
||||||
gint x,
|
gint x,
|
||||||
gint y,
|
gint y,
|
||||||
|
gboolean sample_merged,
|
||||||
gboolean sample_average,
|
gboolean sample_average,
|
||||||
gdouble average_radius,
|
gdouble average_radius,
|
||||||
GimpImageType *sample_type,
|
GimpImageType *sample_type,
|
||||||
GimpRGB *color,
|
GimpRGB *color,
|
||||||
gint *color_index)
|
gint *color_index)
|
||||||
{
|
{
|
||||||
GimpRGB rgb_color;
|
GimpImageType my_sample_type;
|
||||||
guchar *col;
|
gboolean is_indexed;
|
||||||
GimpImageType my_sample_type;
|
GimpImagePickColorFunc color_func;
|
||||||
gint my_color_index;
|
GimpObject *color_obj;
|
||||||
gboolean has_alpha;
|
|
||||||
gboolean is_indexed;
|
|
||||||
GetColorFunc get_color_func;
|
|
||||||
GimpObject *get_color_obj;
|
|
||||||
|
|
||||||
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), FALSE);
|
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), FALSE);
|
||||||
g_return_val_if_fail (sample_merged || GIMP_IS_DRAWABLE (drawable), FALSE);
|
g_return_val_if_fail (sample_merged || GIMP_IS_DRAWABLE (drawable), FALSE);
|
||||||
@ -61,7 +53,15 @@ gimp_image_pick_color (GimpImage *gimage,
|
|||||||
gimp_item_get_image (GIMP_ITEM (drawable)) == gimage,
|
gimp_item_get_image (GIMP_ITEM (drawable)) == gimage,
|
||||||
FALSE);
|
FALSE);
|
||||||
|
|
||||||
if (! sample_merged)
|
if (sample_merged)
|
||||||
|
{
|
||||||
|
my_sample_type = gimp_image_projection_type (gimage);
|
||||||
|
is_indexed = FALSE;
|
||||||
|
|
||||||
|
color_func = (GimpImagePickColorFunc) gimp_image_projection_get_color_at;
|
||||||
|
color_obj = GIMP_OBJECT (gimage);
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
gint off_x, off_y;
|
gint off_x, off_y;
|
||||||
|
|
||||||
@ -72,21 +72,31 @@ gimp_image_pick_color (GimpImage *gimage,
|
|||||||
my_sample_type = gimp_drawable_type (drawable);
|
my_sample_type = gimp_drawable_type (drawable);
|
||||||
is_indexed = gimp_drawable_is_indexed (drawable);
|
is_indexed = gimp_drawable_is_indexed (drawable);
|
||||||
|
|
||||||
get_color_func = (GetColorFunc) gimp_drawable_get_color_at;
|
color_func = (GimpImagePickColorFunc) gimp_drawable_get_color_at;
|
||||||
get_color_obj = GIMP_OBJECT (drawable);
|
color_obj = GIMP_OBJECT (drawable);
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
my_sample_type = gimp_image_projection_type (gimage);
|
|
||||||
is_indexed = FALSE;
|
|
||||||
|
|
||||||
get_color_func = (GetColorFunc) gimp_image_projection_get_color_at;
|
|
||||||
get_color_obj = GIMP_OBJECT (gimage);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
has_alpha = GIMP_IMAGE_TYPE_HAS_ALPHA (my_sample_type);
|
if (sample_type)
|
||||||
|
*sample_type = my_sample_type;
|
||||||
|
|
||||||
if (! (col = (* get_color_func) (get_color_obj, x, y)))
|
return gimp_image_pick_color_by_func (color_obj, x, y, color_func,
|
||||||
|
sample_average, average_radius,
|
||||||
|
color, color_index);
|
||||||
|
}
|
||||||
|
|
||||||
|
gboolean
|
||||||
|
gimp_image_pick_color_by_func (GimpObject *object,
|
||||||
|
gint x,
|
||||||
|
gint y,
|
||||||
|
GimpImagePickColorFunc pick_color_func,
|
||||||
|
gboolean sample_average,
|
||||||
|
gdouble average_radius,
|
||||||
|
GimpRGB *color,
|
||||||
|
gint *color_index)
|
||||||
|
{
|
||||||
|
guchar *col;
|
||||||
|
|
||||||
|
if (! (col = pick_color_func (object, x, y)))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
if (sample_average)
|
if (sample_average)
|
||||||
@ -99,16 +109,14 @@ gimp_image_pick_color (GimpImage *gimage,
|
|||||||
|
|
||||||
for (i = x - radius; i <= x + radius; i++)
|
for (i = x - radius; i <= x + radius; i++)
|
||||||
for (j = y - radius; j <= y + radius; j++)
|
for (j = y - radius; j <= y + radius; j++)
|
||||||
if ((tmp_col = (* get_color_func) (get_color_obj, i, j)))
|
if ((tmp_col = pick_color_func (object, i, j)))
|
||||||
{
|
{
|
||||||
count++;
|
count++;
|
||||||
|
|
||||||
color_avg[RED_PIX] += tmp_col[RED_PIX];
|
color_avg[RED_PIX] += tmp_col[RED_PIX];
|
||||||
color_avg[GREEN_PIX] += tmp_col[GREEN_PIX];
|
color_avg[GREEN_PIX] += tmp_col[GREEN_PIX];
|
||||||
color_avg[BLUE_PIX] += tmp_col[BLUE_PIX];
|
color_avg[BLUE_PIX] += tmp_col[BLUE_PIX];
|
||||||
|
color_avg[ALPHA_PIX] += tmp_col[ALPHA_PIX];
|
||||||
if (has_alpha)
|
|
||||||
color_avg[ALPHA_PIX] += tmp_col[ALPHA_PIX];
|
|
||||||
|
|
||||||
g_free (tmp_col);
|
g_free (tmp_col);
|
||||||
}
|
}
|
||||||
@ -116,41 +124,20 @@ gimp_image_pick_color (GimpImage *gimage,
|
|||||||
col[RED_PIX] = (guchar) (color_avg[RED_PIX] / count);
|
col[RED_PIX] = (guchar) (color_avg[RED_PIX] / count);
|
||||||
col[GREEN_PIX] = (guchar) (color_avg[GREEN_PIX] / count);
|
col[GREEN_PIX] = (guchar) (color_avg[GREEN_PIX] / count);
|
||||||
col[BLUE_PIX] = (guchar) (color_avg[BLUE_PIX] / count);
|
col[BLUE_PIX] = (guchar) (color_avg[BLUE_PIX] / count);
|
||||||
|
col[ALPHA_PIX] = (guchar) (color_avg[ALPHA_PIX] / count);
|
||||||
if (has_alpha)
|
|
||||||
col[ALPHA_PIX] = (guchar) (color_avg[ALPHA_PIX] / count);
|
|
||||||
|
|
||||||
is_indexed = FALSE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_indexed)
|
if (color)
|
||||||
my_color_index = col[4];
|
gimp_rgba_set_uchar (color,
|
||||||
else
|
|
||||||
my_color_index = -1;
|
|
||||||
|
|
||||||
if (has_alpha)
|
|
||||||
gimp_rgba_set_uchar (&rgb_color,
|
|
||||||
col[RED_PIX],
|
col[RED_PIX],
|
||||||
col[GREEN_PIX],
|
col[GREEN_PIX],
|
||||||
col[BLUE_PIX],
|
col[BLUE_PIX],
|
||||||
col[ALPHA_PIX]);
|
col[ALPHA_PIX]);
|
||||||
else
|
|
||||||
gimp_rgba_set_uchar (&rgb_color,
|
if (color_index)
|
||||||
col[RED_PIX],
|
*color_index = sample_average ? -1 : col[4];
|
||||||
col[GREEN_PIX],
|
|
||||||
col[BLUE_PIX],
|
|
||||||
OPAQUE_OPACITY);
|
|
||||||
|
|
||||||
g_free (col);
|
g_free (col);
|
||||||
|
|
||||||
if (sample_type)
|
|
||||||
*sample_type = my_sample_type;
|
|
||||||
|
|
||||||
if (color)
|
|
||||||
*color = rgb_color;
|
|
||||||
|
|
||||||
if (color_index)
|
|
||||||
*color_index = my_color_index;
|
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
@ -20,16 +20,30 @@
|
|||||||
#define __GIMP_IMAGE_PICK_COLOR_H__
|
#define __GIMP_IMAGE_PICK_COLOR_H__
|
||||||
|
|
||||||
|
|
||||||
gboolean gimp_image_pick_color (GimpImage *gimage,
|
typedef guchar * (* GimpImagePickColorFunc) (GimpObject *object,
|
||||||
GimpDrawable *drawable,
|
gint x,
|
||||||
gboolean sample_merged,
|
gint y);
|
||||||
gint x,
|
|
||||||
gint y,
|
|
||||||
gboolean sample_average,
|
gboolean gimp_image_pick_color (GimpImage *gimage,
|
||||||
gdouble average_radius,
|
GimpDrawable *drawable,
|
||||||
GimpImageType *sample_type,
|
gint x,
|
||||||
GimpRGB *color,
|
gint y,
|
||||||
gint *color_index);
|
gboolean sample_merged,
|
||||||
|
gboolean sample_average,
|
||||||
|
gdouble average_radius,
|
||||||
|
GimpImageType *sample_type,
|
||||||
|
GimpRGB *color,
|
||||||
|
gint *color_index);
|
||||||
|
|
||||||
|
gboolean gimp_image_pick_color_by_func (GimpObject *object,
|
||||||
|
gint x,
|
||||||
|
gint y,
|
||||||
|
GimpImagePickColorFunc pick_color_func,
|
||||||
|
gboolean sample_average,
|
||||||
|
gdouble average_radius,
|
||||||
|
GimpRGB *color,
|
||||||
|
gint *color_index);
|
||||||
|
|
||||||
|
|
||||||
#endif /* __GIMP_IMAGE_PICK_COLOR_H__ */
|
#endif /* __GIMP_IMAGE_PICK_COLOR_H__ */
|
||||||
|
@ -198,7 +198,7 @@ gimp_image_projection_get_color_at (GimpImage *gimage,
|
|||||||
if (GIMP_IMAGE_TYPE_HAS_ALPHA (gimp_image_projection_type (gimage)))
|
if (GIMP_IMAGE_TYPE_HAS_ALPHA (gimp_image_projection_type (gimage)))
|
||||||
dest[3] = src[gimp_image_projection_bytes (gimage) - 1];
|
dest[3] = src[gimp_image_projection_bytes (gimage) - 1];
|
||||||
else
|
else
|
||||||
dest[3] = 255;
|
dest[3] = OPAQUE_OPACITY;
|
||||||
|
|
||||||
dest[4] = 0;
|
dest[4] = 0;
|
||||||
tile_release (tile, FALSE);
|
tile_release (tile, FALSE);
|
||||||
|
@ -198,7 +198,7 @@ gimp_image_projection_get_color_at (GimpImage *gimage,
|
|||||||
if (GIMP_IMAGE_TYPE_HAS_ALPHA (gimp_image_projection_type (gimage)))
|
if (GIMP_IMAGE_TYPE_HAS_ALPHA (gimp_image_projection_type (gimage)))
|
||||||
dest[3] = src[gimp_image_projection_bytes (gimage) - 1];
|
dest[3] = src[gimp_image_projection_bytes (gimage) - 1];
|
||||||
else
|
else
|
||||||
dest[3] = 255;
|
dest[3] = OPAQUE_OPACITY;
|
||||||
|
|
||||||
dest[4] = 0;
|
dest[4] = 0;
|
||||||
tile_release (tile, FALSE);
|
tile_release (tile, FALSE);
|
||||||
|
@ -184,12 +184,6 @@ gimp_color_options_gui (GimpToolOptions *tool_options)
|
|||||||
|
|
||||||
vbox = gimp_tool_options_gui (tool_options);
|
vbox = gimp_tool_options_gui (tool_options);
|
||||||
|
|
||||||
/* the sample merged toggle button */
|
|
||||||
button = gimp_prop_check_button_new (config, "sample-merged",
|
|
||||||
_("Sample Merged"));
|
|
||||||
gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
|
|
||||||
gtk_widget_show (button);
|
|
||||||
|
|
||||||
/* the sample average options */
|
/* the sample average options */
|
||||||
frame = gtk_frame_new (NULL);
|
frame = gtk_frame_new (NULL);
|
||||||
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_ETCHED_IN);
|
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_ETCHED_IN);
|
||||||
|
@ -163,6 +163,12 @@ gimp_color_picker_options_gui (GimpToolOptions *tool_options)
|
|||||||
|
|
||||||
vbox = gimp_color_options_gui (tool_options);
|
vbox = gimp_color_options_gui (tool_options);
|
||||||
|
|
||||||
|
/* the sample merged toggle button */
|
||||||
|
button = gimp_prop_check_button_new (config, "sample-merged",
|
||||||
|
_("Sample Merged"));
|
||||||
|
gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
|
||||||
|
gtk_widget_show (button);
|
||||||
|
|
||||||
/* the update active color toggle button */
|
/* the update active color toggle button */
|
||||||
button = gimp_prop_check_button_new (config, "update-active",
|
button = gimp_prop_check_button_new (config, "update-active",
|
||||||
_("Update Active Color"));
|
_("Update Active Color"));
|
||||||
|
@ -259,27 +259,30 @@ gimp_color_tool_cursor_update (GimpTool *tool,
|
|||||||
GdkModifierType state,
|
GdkModifierType state,
|
||||||
GimpDisplay *gdisp)
|
GimpDisplay *gdisp)
|
||||||
{
|
{
|
||||||
if (GIMP_COLOR_TOOL (tool)->enabled)
|
GimpColorTool *color_tool = GIMP_COLOR_TOOL (tool);
|
||||||
|
|
||||||
|
if (color_tool->enabled)
|
||||||
{
|
{
|
||||||
|
GdkCursorType cursor = GIMP_BAD_CURSOR;
|
||||||
|
|
||||||
if (gdisp->gimage &&
|
if (gdisp->gimage &&
|
||||||
|
|
||||||
coords->x > 0 &&
|
coords->x > 0 &&
|
||||||
coords->x < gdisp->gimage->width &&
|
coords->x < gdisp->gimage->width &&
|
||||||
coords->y > 0 &&
|
coords->y > 0 &&
|
||||||
coords->y < gdisp->gimage->height)
|
coords->y < gdisp->gimage->height &&
|
||||||
|
|
||||||
|
(color_tool->options->sample_merged ||
|
||||||
|
gimp_display_coords_in_active_drawable (gdisp, coords)))
|
||||||
{
|
{
|
||||||
gimp_tool_set_cursor (tool, gdisp,
|
cursor = GIMP_COLOR_PICKER_CURSOR;
|
||||||
GIMP_COLOR_PICKER_CURSOR,
|
|
||||||
GIMP_COLOR_PICKER_TOOL_CURSOR,
|
|
||||||
GIMP_CURSOR_MODIFIER_NONE);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
gimp_tool_set_cursor (tool, gdisp,
|
|
||||||
GIMP_BAD_CURSOR,
|
|
||||||
GIMP_COLOR_PICKER_TOOL_CURSOR,
|
|
||||||
GIMP_CURSOR_MODIFIER_NONE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gimp_tool_set_cursor (tool, gdisp,
|
||||||
|
cursor,
|
||||||
|
GIMP_COLOR_PICKER_TOOL_CURSOR,
|
||||||
|
GIMP_CURSOR_MODIFIER_NONE);
|
||||||
|
|
||||||
return; /* don't chain up */
|
return; /* don't chain up */
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -323,10 +326,8 @@ gimp_color_tool_real_pick (GimpColorTool *color_tool,
|
|||||||
g_return_val_if_fail (tool->gdisp != NULL, FALSE);
|
g_return_val_if_fail (tool->gdisp != NULL, FALSE);
|
||||||
g_return_val_if_fail (tool->drawable != NULL, FALSE);
|
g_return_val_if_fail (tool->drawable != NULL, FALSE);
|
||||||
|
|
||||||
return gimp_image_pick_color (tool->gdisp->gimage,
|
return gimp_image_pick_color (tool->gdisp->gimage, tool->drawable, x, y,
|
||||||
tool->drawable,
|
|
||||||
color_tool->options->sample_merged,
|
color_tool->options->sample_merged,
|
||||||
x, y,
|
|
||||||
color_tool->options->sample_average,
|
color_tool->options->sample_average,
|
||||||
color_tool->options->average_radius,
|
color_tool->options->average_radius,
|
||||||
sample_type,
|
sample_type,
|
||||||
|
@ -26,6 +26,7 @@
|
|||||||
|
|
||||||
#include "core/gimpdrawable.h"
|
#include "core/gimpdrawable.h"
|
||||||
#include "core/gimpimage.h"
|
#include "core/gimpimage.h"
|
||||||
|
#include "core/gimpimage-pick-color.h"
|
||||||
#include "core/gimpimagemap.h"
|
#include "core/gimpimagemap.h"
|
||||||
#include "core/gimptoolinfo.h"
|
#include "core/gimptoolinfo.h"
|
||||||
|
|
||||||
@ -36,6 +37,7 @@
|
|||||||
#include "display/gimpdisplay.h"
|
#include "display/gimpdisplay.h"
|
||||||
#include "display/gimpdisplayshell.h"
|
#include "display/gimpdisplayshell.h"
|
||||||
|
|
||||||
|
#include "gimpcoloroptions.h"
|
||||||
#include "gimpimagemaptool.h"
|
#include "gimpimagemaptool.h"
|
||||||
#include "gimptoolcontrol.h"
|
#include "gimptoolcontrol.h"
|
||||||
|
|
||||||
@ -55,6 +57,12 @@ static void gimp_image_map_tool_control (GimpTool *tool,
|
|||||||
GimpToolAction action,
|
GimpToolAction action,
|
||||||
GimpDisplay *gdisp);
|
GimpDisplay *gdisp);
|
||||||
|
|
||||||
|
static gboolean gimp_image_map_tool_pick_color (GimpColorTool *color_tool,
|
||||||
|
gint x,
|
||||||
|
gint y,
|
||||||
|
GimpImageType *sample_type,
|
||||||
|
GimpRGB *color,
|
||||||
|
gint *color_index);
|
||||||
static void gimp_image_map_tool_map (GimpImageMapTool *image_map_tool);
|
static void gimp_image_map_tool_map (GimpImageMapTool *image_map_tool);
|
||||||
static void gimp_image_map_tool_dialog (GimpImageMapTool *image_map_tool);
|
static void gimp_image_map_tool_dialog (GimpImageMapTool *image_map_tool);
|
||||||
static void gimp_image_map_tool_reset (GimpImageMapTool *image_map_tool);
|
static void gimp_image_map_tool_reset (GimpImageMapTool *image_map_tool);
|
||||||
@ -95,7 +103,7 @@ gimp_image_map_tool_get_type (void)
|
|||||||
(GInstanceInitFunc) gimp_image_map_tool_init,
|
(GInstanceInitFunc) gimp_image_map_tool_init,
|
||||||
};
|
};
|
||||||
|
|
||||||
tool_type = g_type_register_static (GIMP_TYPE_TOOL,
|
tool_type = g_type_register_static (GIMP_TYPE_COLOR_TOOL,
|
||||||
"GimpImageMapTool",
|
"GimpImageMapTool",
|
||||||
&tool_info, 0);
|
&tool_info, 0);
|
||||||
}
|
}
|
||||||
@ -106,11 +114,13 @@ gimp_image_map_tool_get_type (void)
|
|||||||
static void
|
static void
|
||||||
gimp_image_map_tool_class_init (GimpImageMapToolClass *klass)
|
gimp_image_map_tool_class_init (GimpImageMapToolClass *klass)
|
||||||
{
|
{
|
||||||
GObjectClass *object_class;
|
GObjectClass *object_class;
|
||||||
GimpToolClass *tool_class;
|
GimpToolClass *tool_class;
|
||||||
|
GimpColorToolClass *color_tool_class;
|
||||||
|
|
||||||
object_class = G_OBJECT_CLASS (klass);
|
object_class = G_OBJECT_CLASS (klass);
|
||||||
tool_class = GIMP_TOOL_CLASS (klass);
|
tool_class = GIMP_TOOL_CLASS (klass);
|
||||||
|
color_tool_class = GIMP_COLOR_TOOL_CLASS (klass);
|
||||||
|
|
||||||
parent_class = g_type_class_peek_parent (klass);
|
parent_class = g_type_class_peek_parent (klass);
|
||||||
|
|
||||||
@ -119,6 +129,8 @@ gimp_image_map_tool_class_init (GimpImageMapToolClass *klass)
|
|||||||
tool_class->initialize = gimp_image_map_tool_initialize;
|
tool_class->initialize = gimp_image_map_tool_initialize;
|
||||||
tool_class->control = gimp_image_map_tool_control;
|
tool_class->control = gimp_image_map_tool_control;
|
||||||
|
|
||||||
|
color_tool_class->pick = gimp_image_map_tool_pick_color;
|
||||||
|
|
||||||
klass->map = NULL;
|
klass->map = NULL;
|
||||||
klass->dialog = NULL;
|
klass->dialog = NULL;
|
||||||
klass->reset = NULL;
|
klass->reset = NULL;
|
||||||
@ -288,18 +300,10 @@ gimp_image_map_tool_control (GimpTool *tool,
|
|||||||
GimpToolAction action,
|
GimpToolAction action,
|
||||||
GimpDisplay *gdisp)
|
GimpDisplay *gdisp)
|
||||||
{
|
{
|
||||||
GimpImageMapTool *image_map_tool;
|
GimpImageMapTool *image_map_tool = GIMP_IMAGE_MAP_TOOL (tool);
|
||||||
|
|
||||||
image_map_tool = GIMP_IMAGE_MAP_TOOL (tool);
|
|
||||||
|
|
||||||
switch (action)
|
switch (action)
|
||||||
{
|
{
|
||||||
case PAUSE:
|
|
||||||
break;
|
|
||||||
|
|
||||||
case RESUME:
|
|
||||||
break;
|
|
||||||
|
|
||||||
case HALT:
|
case HALT:
|
||||||
if (image_map_tool->shell)
|
if (image_map_tool->shell)
|
||||||
gimp_image_map_tool_cancel_clicked (NULL, image_map_tool);
|
gimp_image_map_tool_cancel_clicked (NULL, image_map_tool);
|
||||||
@ -312,6 +316,25 @@ gimp_image_map_tool_control (GimpTool *tool,
|
|||||||
GIMP_TOOL_CLASS (parent_class)->control (tool, action, gdisp);
|
GIMP_TOOL_CLASS (parent_class)->control (tool, action, gdisp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
gimp_image_map_tool_pick_color (GimpColorTool *color_tool,
|
||||||
|
gint x,
|
||||||
|
gint y,
|
||||||
|
GimpImageType *sample_type,
|
||||||
|
GimpRGB *color,
|
||||||
|
gint *color_index)
|
||||||
|
{
|
||||||
|
GimpImageMapTool *tool = GIMP_IMAGE_MAP_TOOL (color_tool);
|
||||||
|
|
||||||
|
*sample_type = gimp_drawable_type (tool->drawable);
|
||||||
|
|
||||||
|
return gimp_image_pick_color_by_func (GIMP_OBJECT (tool->image_map), x, y,
|
||||||
|
(GimpImagePickColorFunc) gimp_image_map_get_color_at,
|
||||||
|
color_tool->options->sample_average,
|
||||||
|
color_tool->options->average_radius,
|
||||||
|
color, color_index);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gimp_image_map_tool_map (GimpImageMapTool *image_map_tool)
|
gimp_image_map_tool_map (GimpImageMapTool *image_map_tool)
|
||||||
{
|
{
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
#define __GIMP_IMAGE_MAP_TOOL_H__
|
#define __GIMP_IMAGE_MAP_TOOL_H__
|
||||||
|
|
||||||
|
|
||||||
#include "gimptool.h"
|
#include "gimpcolortool.h"
|
||||||
|
|
||||||
|
|
||||||
#define GIMP_TYPE_IMAGE_MAP_TOOL (gimp_image_map_tool_get_type ())
|
#define GIMP_TYPE_IMAGE_MAP_TOOL (gimp_image_map_tool_get_type ())
|
||||||
@ -35,24 +35,24 @@ typedef struct _GimpImageMapToolClass GimpImageMapToolClass;
|
|||||||
|
|
||||||
struct _GimpImageMapTool
|
struct _GimpImageMapTool
|
||||||
{
|
{
|
||||||
GimpTool parent_instance;
|
GimpColorTool parent_instance;
|
||||||
|
|
||||||
GimpDrawable *drawable;
|
GimpDrawable *drawable;
|
||||||
GimpImageMap *image_map;
|
GimpImageMap *image_map;
|
||||||
|
|
||||||
gboolean preview;
|
gboolean preview;
|
||||||
|
|
||||||
/* the dialog */
|
/* the dialog */
|
||||||
const gchar *shell_identifier;
|
const gchar *shell_identifier;
|
||||||
const gchar *shell_desc;
|
const gchar *shell_desc;
|
||||||
|
|
||||||
GtkWidget *shell;
|
GtkWidget *shell;
|
||||||
GtkWidget *main_vbox;
|
GtkWidget *main_vbox;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct _GimpImageMapToolClass
|
struct _GimpImageMapToolClass
|
||||||
{
|
{
|
||||||
GimpToolClass parent_class;
|
GimpColorToolClass parent_class;
|
||||||
|
|
||||||
/* virtual functions */
|
/* virtual functions */
|
||||||
void (* map) (GimpImageMapTool *image_map_tool);
|
void (* map) (GimpImageMapTool *image_map_tool);
|
||||||
|
@ -31,6 +31,7 @@
|
|||||||
#include <gtk/gtk.h>
|
#include <gtk/gtk.h>
|
||||||
|
|
||||||
#include "libgimpbase/gimpbase.h"
|
#include "libgimpbase/gimpbase.h"
|
||||||
|
#include "libgimpcolor/gimpcolor.h"
|
||||||
#include "libgimpwidgets/gimpwidgets.h"
|
#include "libgimpwidgets/gimpwidgets.h"
|
||||||
|
|
||||||
#include "tools-types.h"
|
#include "tools-types.h"
|
||||||
@ -53,6 +54,7 @@
|
|||||||
|
|
||||||
#include "display/gimpdisplay.h"
|
#include "display/gimpdisplay.h"
|
||||||
|
|
||||||
|
#include "gimpcoloroptions.h"
|
||||||
#include "gimplevelstool.h"
|
#include "gimplevelstool.h"
|
||||||
#include "gimptoolcontrol.h"
|
#include "gimptoolcontrol.h"
|
||||||
|
|
||||||
@ -93,21 +95,11 @@ static void gimp_levels_tool_finalize (GObject *object);
|
|||||||
|
|
||||||
static void gimp_levels_tool_initialize (GimpTool *tool,
|
static void gimp_levels_tool_initialize (GimpTool *tool,
|
||||||
GimpDisplay *gdisp);
|
GimpDisplay *gdisp);
|
||||||
static void gimp_levels_tool_button_press (GimpTool *tool,
|
|
||||||
GimpCoords *coords,
|
|
||||||
guint32 time,
|
|
||||||
GdkModifierType state,
|
|
||||||
GimpDisplay *gdisp);
|
|
||||||
static void gimp_levels_tool_motion (GimpTool *tool,
|
|
||||||
GimpCoords *coords,
|
|
||||||
guint32 time,
|
|
||||||
GdkModifierType state,
|
|
||||||
GimpDisplay *gdisp);
|
|
||||||
static void gimp_levels_tool_cursor_update (GimpTool *tool,
|
|
||||||
GimpCoords *coords,
|
|
||||||
GdkModifierType state,
|
|
||||||
GimpDisplay *gdisp);
|
|
||||||
|
|
||||||
|
static void gimp_levels_tool_color_picked (GimpColorTool *color_tool,
|
||||||
|
GimpImageType sample_type,
|
||||||
|
GimpRGB *color,
|
||||||
|
gint color_index);
|
||||||
static void gimp_levels_tool_map (GimpImageMapTool *image_map_tool);
|
static void gimp_levels_tool_map (GimpImageMapTool *image_map_tool);
|
||||||
static void gimp_levels_tool_dialog (GimpImageMapTool *image_map_tool);
|
static void gimp_levels_tool_dialog (GimpImageMapTool *image_map_tool);
|
||||||
static void gimp_levels_tool_reset (GimpImageMapTool *image_map_tool);
|
static void gimp_levels_tool_reset (GimpImageMapTool *image_map_tool);
|
||||||
@ -143,9 +135,6 @@ static gint levels_input_da_events (GtkWidget *widget,
|
|||||||
static gint levels_output_da_events (GtkWidget *widget,
|
static gint levels_output_da_events (GtkWidget *widget,
|
||||||
GdkEvent *event,
|
GdkEvent *event,
|
||||||
GimpLevelsTool *l_tool);
|
GimpLevelsTool *l_tool);
|
||||||
static void levels_input_color_pick (GimpTool *tool,
|
|
||||||
GimpDrawable *drawable,
|
|
||||||
GimpCoords *coords);
|
|
||||||
|
|
||||||
static void file_dialog_create (GimpLevelsTool *l_tool);
|
static void file_dialog_create (GimpLevelsTool *l_tool);
|
||||||
static void file_dialog_ok_callback (GimpLevelsTool *l_tool);
|
static void file_dialog_ok_callback (GimpLevelsTool *l_tool);
|
||||||
@ -166,7 +155,8 @@ gimp_levels_tool_register (GimpToolRegisterCallback callback,
|
|||||||
gpointer data)
|
gpointer data)
|
||||||
{
|
{
|
||||||
(* callback) (GIMP_TYPE_LEVELS_TOOL,
|
(* callback) (GIMP_TYPE_LEVELS_TOOL,
|
||||||
G_TYPE_NONE, NULL,
|
GIMP_TYPE_COLOR_OPTIONS,
|
||||||
|
gimp_color_options_gui,
|
||||||
FALSE,
|
FALSE,
|
||||||
"gimp-levels-tool",
|
"gimp-levels-tool",
|
||||||
_("Levels"),
|
_("Levels"),
|
||||||
@ -213,20 +203,21 @@ gimp_levels_tool_class_init (GimpLevelsToolClass *klass)
|
|||||||
{
|
{
|
||||||
GObjectClass *object_class;
|
GObjectClass *object_class;
|
||||||
GimpToolClass *tool_class;
|
GimpToolClass *tool_class;
|
||||||
|
GimpColorToolClass *color_tool_class;
|
||||||
GimpImageMapToolClass *image_map_tool_class;
|
GimpImageMapToolClass *image_map_tool_class;
|
||||||
|
|
||||||
object_class = G_OBJECT_CLASS (klass);
|
object_class = G_OBJECT_CLASS (klass);
|
||||||
tool_class = GIMP_TOOL_CLASS (klass);
|
tool_class = GIMP_TOOL_CLASS (klass);
|
||||||
|
color_tool_class = GIMP_COLOR_TOOL_CLASS (klass);
|
||||||
image_map_tool_class = GIMP_IMAGE_MAP_TOOL_CLASS (klass);
|
image_map_tool_class = GIMP_IMAGE_MAP_TOOL_CLASS (klass);
|
||||||
|
|
||||||
parent_class = g_type_class_peek_parent (klass);
|
parent_class = g_type_class_peek_parent (klass);
|
||||||
|
|
||||||
object_class->finalize = gimp_levels_tool_finalize;
|
object_class->finalize = gimp_levels_tool_finalize;
|
||||||
|
|
||||||
tool_class->initialize = gimp_levels_tool_initialize;
|
tool_class->initialize = gimp_levels_tool_initialize;
|
||||||
tool_class->button_press = gimp_levels_tool_button_press;
|
|
||||||
tool_class->motion = gimp_levels_tool_motion;
|
color_tool_class->picked = gimp_levels_tool_color_picked;
|
||||||
tool_class->cursor_update = gimp_levels_tool_cursor_update;
|
|
||||||
|
|
||||||
image_map_tool_class->map = gimp_levels_tool_map;
|
image_map_tool_class->map = gimp_levels_tool_map;
|
||||||
image_map_tool_class->dialog = gimp_levels_tool_dialog;
|
image_map_tool_class->dialog = gimp_levels_tool_dialog;
|
||||||
@ -333,50 +324,6 @@ gimp_levels_tool_initialize (GimpTool *tool,
|
|||||||
l_tool->hist);
|
l_tool->hist);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
gimp_levels_tool_button_press (GimpTool *tool,
|
|
||||||
GimpCoords *coords,
|
|
||||||
guint32 time,
|
|
||||||
GdkModifierType state,
|
|
||||||
GimpDisplay *gdisp)
|
|
||||||
{
|
|
||||||
levels_input_color_pick (tool, tool->drawable, coords);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
gimp_levels_tool_motion (GimpTool *tool,
|
|
||||||
GimpCoords *coords,
|
|
||||||
guint32 time,
|
|
||||||
GdkModifierType state,
|
|
||||||
GimpDisplay *gdisp)
|
|
||||||
{
|
|
||||||
levels_input_color_pick (tool, tool->drawable, coords);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
gimp_levels_tool_cursor_update (GimpTool *tool,
|
|
||||||
GimpCoords *coords,
|
|
||||||
GdkModifierType state,
|
|
||||||
GimpDisplay *gdisp)
|
|
||||||
{
|
|
||||||
if (GIMP_LEVELS_TOOL (tool)->active_picker)
|
|
||||||
{
|
|
||||||
gimp_tool_control_set_tool_cursor (tool->control,
|
|
||||||
GIMP_COLOR_PICKER_TOOL_CURSOR);
|
|
||||||
gimp_tool_control_set_cursor (tool->control,
|
|
||||||
gimp_display_coords_in_active_drawable (gdisp,
|
|
||||||
coords) ?
|
|
||||||
GIMP_MOUSE_CURSOR : GIMP_BAD_CURSOR);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
gimp_tool_control_set_tool_cursor (tool->control, GIMP_TOOL_CURSOR_NONE);
|
|
||||||
gimp_tool_control_set_cursor (tool->control, GIMP_MOUSE_CURSOR);
|
|
||||||
}
|
|
||||||
|
|
||||||
GIMP_TOOL_CLASS (parent_class)->cursor_update (tool, coords, state, gdisp);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gimp_levels_tool_map (GimpImageMapTool *image_map_tool)
|
gimp_levels_tool_map (GimpImageMapTool *image_map_tool)
|
||||||
{
|
{
|
||||||
@ -1173,11 +1120,15 @@ levels_input_picker_toggled (GtkWidget *widget,
|
|||||||
FALSE);
|
FALSE);
|
||||||
|
|
||||||
tool->active_picker = widget;
|
tool->active_picker = widget;
|
||||||
|
|
||||||
|
gimp_color_tool_enable (GIMP_COLOR_TOOL (tool),
|
||||||
|
GIMP_COLOR_OPTIONS (GIMP_TOOL (tool)->tool_info->tool_options));
|
||||||
}
|
}
|
||||||
else if (tool->active_picker == widget)
|
else if (tool->active_picker == widget)
|
||||||
{
|
{
|
||||||
tool->active_picker = NULL;
|
tool->active_picker = NULL;
|
||||||
}
|
gimp_color_tool_disable (GIMP_COLOR_TOOL (tool));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
@ -1394,34 +1345,27 @@ levels_input_adjust_by_color (Levels *levels,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
levels_input_color_pick (GimpTool *tool,
|
gimp_levels_tool_color_picked (GimpColorTool *color_tool,
|
||||||
GimpDrawable *drawable,
|
GimpImageType sample_type,
|
||||||
GimpCoords *coords)
|
GimpRGB *color,
|
||||||
|
gint color_index)
|
||||||
{
|
{
|
||||||
GimpLevelsTool *l_tool;
|
GimpLevelsTool *l_tool;
|
||||||
guchar *color;
|
guchar col[5];
|
||||||
guint value;
|
guint value;
|
||||||
gint x, y;
|
|
||||||
|
|
||||||
l_tool = GIMP_LEVELS_TOOL (tool);
|
l_tool = GIMP_LEVELS_TOOL (color_tool);
|
||||||
|
|
||||||
if (! l_tool->active_picker || !drawable)
|
gimp_rgba_get_uchar (color,
|
||||||
return;
|
col + RED_PIX,
|
||||||
|
col + GREEN_PIX,
|
||||||
gimp_item_offsets (GIMP_ITEM (drawable), &x, &y);
|
col + BLUE_PIX,
|
||||||
|
col + ALPHA_PIX);
|
||||||
x = RINT (coords->x) - x;
|
|
||||||
y = RINT (coords->y) - y;
|
|
||||||
|
|
||||||
color = gimp_image_map_get_color_at (GIMP_IMAGE_MAP_TOOL (tool)->image_map,
|
|
||||||
x, y);
|
|
||||||
if (!color)
|
|
||||||
return;
|
|
||||||
|
|
||||||
value = GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (l_tool->active_picker),
|
value = GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (l_tool->active_picker),
|
||||||
"pick_value"));
|
"pick_value"));
|
||||||
|
|
||||||
if (value & ALL_CHANNELS && GIMP_IMAGE_TYPE_IS_RGB (drawable->type))
|
if (value & ALL_CHANNELS && GIMP_IMAGE_TYPE_IS_RGB (sample_type))
|
||||||
{
|
{
|
||||||
GimpHistogramChannel channel;
|
GimpHistogramChannel channel;
|
||||||
|
|
||||||
@ -1446,20 +1390,19 @@ levels_input_color_pick (GimpTool *tool,
|
|||||||
channel <= GIMP_HISTOGRAM_BLUE;
|
channel <= GIMP_HISTOGRAM_BLUE;
|
||||||
channel++)
|
channel++)
|
||||||
{
|
{
|
||||||
levels_input_adjust_by_color (l_tool->levels, value, channel, color);
|
levels_input_adjust_by_color (l_tool->levels,
|
||||||
|
value, channel, col);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
levels_input_adjust_by_color (l_tool->levels,
|
levels_input_adjust_by_color (l_tool->levels,
|
||||||
value, l_tool->channel, color);
|
value, l_tool->channel, col);
|
||||||
}
|
}
|
||||||
|
|
||||||
levels_update (l_tool, ALL);
|
levels_update (l_tool, ALL);
|
||||||
|
|
||||||
gimp_image_map_tool_preview (GIMP_IMAGE_MAP_TOOL (l_tool));
|
gimp_image_map_tool_preview (GIMP_IMAGE_MAP_TOOL (l_tool));
|
||||||
|
|
||||||
g_free (color);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
Reference in New Issue
Block a user