2006-12-10 05:33:38 +08:00
|
|
|
/* GIMP - The GNU Image Manipulation Program
|
1997-11-25 06:05:25 +08:00
|
|
|
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
|
|
|
*
|
2006-07-31 19:42:51 +08:00
|
|
|
* gimpbycolorselecttool.c
|
|
|
|
*
|
2009-01-18 06:28:01 +08:00
|
|
|
* This program is free software: you can redistribute it and/or modify
|
1997-11-25 06:05:25 +08:00
|
|
|
* it under the terms of the GNU General Public License as published by
|
2009-01-18 06:28:01 +08:00
|
|
|
* the Free Software Foundation; either version 3 of the License, or
|
1997-11-25 06:05:25 +08:00
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
2009-01-18 06:28:01 +08:00
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
1997-11-25 06:05:25 +08:00
|
|
|
*/
|
2000-12-17 05:37:03 +08:00
|
|
|
|
2000-04-28 01:27:28 +08:00
|
|
|
#include "config.h"
|
|
|
|
|
2008-05-23 22:09:55 +08:00
|
|
|
#include <string.h>
|
|
|
|
|
2008-10-10 04:24:04 +08:00
|
|
|
#include <gegl.h>
|
2000-12-17 05:37:03 +08:00
|
|
|
#include <gtk/gtk.h>
|
2000-03-08 04:00:07 +08:00
|
|
|
|
2001-01-24 20:21:50 +08:00
|
|
|
#include "libgimpcolor/gimpcolor.h"
|
2001-01-25 06:36:18 +08:00
|
|
|
#include "libgimpwidgets/gimpwidgets.h"
|
2001-01-24 20:21:50 +08:00
|
|
|
|
2001-05-10 16:10:25 +08:00
|
|
|
#include "tools-types.h"
|
2000-12-17 05:37:03 +08:00
|
|
|
|
2001-11-28 11:08:03 +08:00
|
|
|
#include "core/gimpimage.h"
|
2006-07-31 19:42:51 +08:00
|
|
|
#include "core/gimpimage-contiguous-region.h"
|
|
|
|
#include "core/gimpitem.h"
|
2004-07-14 07:04:05 +08:00
|
|
|
#include "core/gimppickable.h"
|
2001-05-14 05:51:20 +08:00
|
|
|
|
2003-08-22 09:42:57 +08:00
|
|
|
#include "widgets/gimphelp-ids.h"
|
|
|
|
|
2001-09-26 07:23:09 +08:00
|
|
|
#include "display/gimpdisplay.h"
|
|
|
|
|
2001-05-10 16:10:25 +08:00
|
|
|
#include "gimpbycolorselecttool.h"
|
2008-03-09 23:05:54 +08:00
|
|
|
#include "gimpregionselectoptions.h"
|
2003-04-16 00:05:52 +08:00
|
|
|
#include "gimptoolcontrol.h"
|
2001-05-26 00:04:54 +08:00
|
|
|
|
2003-03-26 00:38:19 +08:00
|
|
|
#include "gimp-intl.h"
|
Lots of ii8n stuff here and some additions to the de.po. Applied
Wed Oct 14 17:46:15 EDT 1998 Adrian Likins <adrian@gimp.org>
* app/*, po/de.po, de/POTFILES.in, libgimp/gimpintl.h:
Lots of ii8n stuff here and some additions to the de.po.
Applied gimp-egger-981005-1 ,gimp-egger-981006-1,
gimp-egger-981007-1, gimp-egger-981008-1,
gimp-egger-981009-1.patch, gimp-egger-981010-1.patch
* plug-in/guillotine/guillotine.c: added the coordinates
of the split images from the original image to the title.
ie foo.jpg (0,0) for the image in the topleft.
* plug-in/script-fu/scripts/neon-logo.scm,
perspective-shadow.scm, predator.scm,rendermap.scm,
ripply-anim.scm, select_to_image.scm,swirltile.scm,
xach-effect.scm: updated scripts to use new script-fu stuff
wooo boy! a big un!
in testing this, it looks like some of the po files are busted.
but the code stuff seems okay.
-adrian
1998-10-15 07:23:52 +08:00
|
|
|
|
2000-12-29 23:22:01 +08:00
|
|
|
|
2006-07-31 19:42:51 +08:00
|
|
|
static GimpChannel * gimp_by_color_select_tool_get_mask (GimpRegionSelectTool *region_select,
|
|
|
|
GimpDisplay *display);
|
2001-10-22 20:13:44 +08:00
|
|
|
|
2006-07-29 04:04:06 +08:00
|
|
|
|
2005-12-13 17:13:50 +08:00
|
|
|
G_DEFINE_TYPE (GimpByColorSelectTool, gimp_by_color_select_tool,
|
2006-07-31 19:42:51 +08:00
|
|
|
GIMP_TYPE_REGION_SELECT_TOOL)
|
2001-10-22 20:13:44 +08:00
|
|
|
|
2005-12-13 17:13:50 +08:00
|
|
|
#define parent_class gimp_by_color_select_tool_parent_class
|
2001-05-10 16:10:25 +08:00
|
|
|
|
|
|
|
|
|
|
|
void
|
2002-03-29 11:50:29 +08:00
|
|
|
gimp_by_color_select_tool_register (GimpToolRegisterCallback callback,
|
2002-05-03 19:31:08 +08:00
|
|
|
gpointer data)
|
2001-05-10 16:10:25 +08:00
|
|
|
{
|
2002-03-29 11:50:29 +08:00
|
|
|
(* callback) (GIMP_TYPE_BY_COLOR_SELECT_TOOL,
|
2008-03-09 23:05:54 +08:00
|
|
|
GIMP_TYPE_REGION_SELECT_OPTIONS,
|
|
|
|
gimp_region_select_options_gui,
|
2003-06-28 19:20:37 +08:00
|
|
|
0,
|
2002-03-21 20:17:17 +08:00
|
|
|
"gimp-by-color-select-tool",
|
2005-08-23 08:18:08 +08:00
|
|
|
_("Select by Color"),
|
2006-09-19 02:00:22 +08:00
|
|
|
_("Select by Color Tool: Select regions with similar colors"),
|
2004-05-05 09:17:23 +08:00
|
|
|
N_("_By Color Select"), "<shift>O",
|
2003-08-22 09:42:57 +08:00
|
|
|
NULL, GIMP_HELP_TOOL_BY_COLOR_SELECT,
|
2002-03-29 11:50:29 +08:00
|
|
|
GIMP_STOCK_TOOL_BY_COLOR_SELECT,
|
2002-05-03 19:31:08 +08:00
|
|
|
data);
|
2001-05-10 16:10:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_by_color_select_tool_class_init (GimpByColorSelectToolClass *klass)
|
|
|
|
{
|
2006-07-31 19:42:51 +08:00
|
|
|
GimpRegionSelectToolClass *region_class;
|
2006-06-14 07:47:20 +08:00
|
|
|
|
2006-07-31 19:42:51 +08:00
|
|
|
region_class = GIMP_REGION_SELECT_TOOL_CLASS (klass);
|
2001-05-10 16:10:25 +08:00
|
|
|
|
2008-05-23 22:09:55 +08:00
|
|
|
region_class->undo_desc = C_("command", "Select by Color");
|
2006-07-31 19:42:51 +08:00
|
|
|
region_class->get_mask = gimp_by_color_select_tool_get_mask;
|
2001-05-10 16:10:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_by_color_select_tool_init (GimpByColorSelectTool *by_color_select)
|
|
|
|
{
|
2006-06-02 04:30:52 +08:00
|
|
|
GimpTool *tool = GIMP_TOOL (by_color_select);
|
|
|
|
|
2006-06-03 23:41:40 +08:00
|
|
|
gimp_tool_control_set_tool_cursor (tool->control, GIMP_TOOL_CURSOR_HAND);
|
2006-06-14 07:47:20 +08:00
|
|
|
}
|
|
|
|
|
2006-07-31 19:42:51 +08:00
|
|
|
static GimpChannel *
|
|
|
|
gimp_by_color_select_tool_get_mask (GimpRegionSelectTool *region_select,
|
|
|
|
GimpDisplay *display)
|
2006-06-14 07:47:20 +08:00
|
|
|
{
|
2008-03-09 23:05:54 +08:00
|
|
|
GimpTool *tool = GIMP_TOOL (region_select);
|
|
|
|
GimpSelectionOptions *sel_options = GIMP_SELECTION_TOOL_GET_OPTIONS (tool);
|
|
|
|
GimpRegionSelectOptions *options = GIMP_REGION_SELECT_TOOL_GET_OPTIONS (tool);
|
2009-10-07 01:20:44 +08:00
|
|
|
GimpImage *image = gimp_display_get_image (display);
|
|
|
|
GimpDrawable *drawable = gimp_image_get_active_drawable (image);
|
2008-03-09 23:05:54 +08:00
|
|
|
GimpPickable *pickable;
|
|
|
|
GimpRGB color;
|
|
|
|
gint x, y;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2006-07-31 19:42:51 +08:00
|
|
|
x = region_select->x;
|
|
|
|
y = region_select->y;
|
2001-11-09 03:14:51 +08:00
|
|
|
|
2003-02-05 22:39:40 +08:00
|
|
|
if (! options->sample_merged)
|
2001-11-09 03:14:51 +08:00
|
|
|
{
|
|
|
|
gint off_x, off_y;
|
|
|
|
|
2008-11-03 07:03:29 +08:00
|
|
|
gimp_item_get_offset (GIMP_ITEM (drawable), &off_x, &off_y);
|
2001-11-09 03:14:51 +08:00
|
|
|
|
2006-07-31 19:42:51 +08:00
|
|
|
x -= off_x;
|
|
|
|
y -= off_y;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2006-07-31 19:42:51 +08:00
|
|
|
pickable = GIMP_PICKABLE (drawable);
|
2001-11-09 03:14:51 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2009-10-07 01:20:44 +08:00
|
|
|
pickable = GIMP_PICKABLE (gimp_image_get_projection (image));
|
2001-11-09 03:14:51 +08:00
|
|
|
}
|
|
|
|
|
2006-07-31 19:42:51 +08:00
|
|
|
gimp_pickable_flush (pickable);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2007-05-03 01:15:03 +08:00
|
|
|
if (gimp_pickable_get_color_at (pickable, x, y, &color))
|
2009-10-07 01:20:44 +08:00
|
|
|
return gimp_image_contiguous_region_by_color (image, drawable,
|
2007-05-03 01:15:03 +08:00
|
|
|
options->sample_merged,
|
2008-03-09 23:05:54 +08:00
|
|
|
sel_options->antialias,
|
2007-05-03 01:15:03 +08:00
|
|
|
options->threshold,
|
|
|
|
options->select_transparent,
|
|
|
|
options->select_criterion,
|
|
|
|
&color);
|
2011-04-04 06:01:30 +08:00
|
|
|
|
|
|
|
return NULL;
|
2006-06-14 07:47:20 +08:00
|
|
|
}
|