2006-12-09 21:33:38 +00:00
|
|
|
/* GIMP - The GNU Image Manipulation Program
|
1997-11-24 22:05:25 +00:00
|
|
|
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
|
|
|
*
|
2006-07-31 11:42:51 +00:00
|
|
|
* gimpbycolorselecttool.c
|
|
|
|
*
|
1997-11-24 22:05:25 +00:00
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (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
|
|
|
|
* along with this program; if not, write to the Free Software
|
1998-04-13 05:44:11 +00:00
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
1997-11-24 22:05:25 +00:00
|
|
|
*/
|
2000-12-16 21:37:03 +00:00
|
|
|
|
2000-04-27 17:27:28 +00:00
|
|
|
#include "config.h"
|
|
|
|
|
2000-12-16 21:37:03 +00:00
|
|
|
#include <gtk/gtk.h>
|
2000-03-07 20:00:07 +00:00
|
|
|
|
2001-01-24 12:21:50 +00:00
|
|
|
#include "libgimpcolor/gimpcolor.h"
|
2001-01-24 22:36:18 +00:00
|
|
|
#include "libgimpwidgets/gimpwidgets.h"
|
2001-01-24 12:21:50 +00:00
|
|
|
|
2001-05-10 08:10:25 +00:00
|
|
|
#include "tools-types.h"
|
2000-12-16 21:37:03 +00:00
|
|
|
|
2001-11-28 03:08:03 +00:00
|
|
|
#include "core/gimpimage.h"
|
2006-07-31 11:42:51 +00:00
|
|
|
#include "core/gimpimage-contiguous-region.h"
|
|
|
|
#include "core/gimpitem.h"
|
2004-07-13 23:04:05 +00:00
|
|
|
#include "core/gimppickable.h"
|
2001-05-13 21:51:20 +00:00
|
|
|
|
2003-08-22 01:42:57 +00:00
|
|
|
#include "widgets/gimphelp-ids.h"
|
|
|
|
|
2001-09-25 23:23:09 +00:00
|
|
|
#include "display/gimpdisplay.h"
|
|
|
|
|
2001-05-10 08:10:25 +00:00
|
|
|
#include "gimpbycolorselecttool.h"
|
2003-02-08 21:12:03 +00:00
|
|
|
#include "gimpselectionoptions.h"
|
2003-04-15 16:05:52 +00:00
|
|
|
#include "gimptoolcontrol.h"
|
2001-05-25 16:04:54 +00:00
|
|
|
|
2003-03-25 16:38:19 +00: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-14 23:23:52 +00:00
|
|
|
|
2000-12-29 15:22:01 +00:00
|
|
|
|
2006-07-31 11:42:51 +00:00
|
|
|
static GimpChannel * gimp_by_color_select_tool_get_mask (GimpRegionSelectTool *region_select,
|
|
|
|
GimpDisplay *display);
|
2001-10-22 12:13:44 +00:00
|
|
|
|
2006-07-28 20:04:06 +00:00
|
|
|
|
2005-12-13 09:13:50 +00:00
|
|
|
G_DEFINE_TYPE (GimpByColorSelectTool, gimp_by_color_select_tool,
|
2006-07-31 11:42:51 +00:00
|
|
|
GIMP_TYPE_REGION_SELECT_TOOL)
|
2001-10-22 12:13:44 +00:00
|
|
|
|
2005-12-13 09:13:50 +00:00
|
|
|
#define parent_class gimp_by_color_select_tool_parent_class
|
2001-05-10 08:10:25 +00:00
|
|
|
|
|
|
|
|
|
|
|
void
|
2002-03-29 03:50:29 +00:00
|
|
|
gimp_by_color_select_tool_register (GimpToolRegisterCallback callback,
|
2002-05-03 11:31:08 +00:00
|
|
|
gpointer data)
|
2001-05-10 08:10:25 +00:00
|
|
|
{
|
2002-03-29 03:50:29 +00:00
|
|
|
(* callback) (GIMP_TYPE_BY_COLOR_SELECT_TOOL,
|
2003-02-05 14:39:40 +00:00
|
|
|
GIMP_TYPE_SELECTION_OPTIONS,
|
|
|
|
gimp_selection_options_gui,
|
2003-06-28 11:20:37 +00:00
|
|
|
0,
|
2002-03-21 12:17:17 +00:00
|
|
|
"gimp-by-color-select-tool",
|
2005-08-23 00:18:08 +00:00
|
|
|
_("Select by Color"),
|
2006-09-18 18:00:22 +00:00
|
|
|
_("Select by Color Tool: Select regions with similar colors"),
|
2004-05-05 01:17:23 +00:00
|
|
|
N_("_By Color Select"), "<shift>O",
|
2003-08-22 01:42:57 +00:00
|
|
|
NULL, GIMP_HELP_TOOL_BY_COLOR_SELECT,
|
2002-03-29 03:50:29 +00:00
|
|
|
GIMP_STOCK_TOOL_BY_COLOR_SELECT,
|
2002-05-03 11:31:08 +00:00
|
|
|
data);
|
2001-05-10 08:10:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_by_color_select_tool_class_init (GimpByColorSelectToolClass *klass)
|
|
|
|
{
|
2006-07-31 11:42:51 +00:00
|
|
|
GimpRegionSelectToolClass *region_class;
|
2006-06-13 23:47:20 +00:00
|
|
|
|
2006-07-31 11:42:51 +00:00
|
|
|
region_class = GIMP_REGION_SELECT_TOOL_CLASS (klass);
|
2001-05-10 08:10:25 +00:00
|
|
|
|
2006-07-31 11:42:51 +00:00
|
|
|
region_class->undo_desc = Q_("command|Select by Color");
|
|
|
|
region_class->get_mask = gimp_by_color_select_tool_get_mask;
|
2001-05-10 08:10:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_by_color_select_tool_init (GimpByColorSelectTool *by_color_select)
|
|
|
|
{
|
2006-06-01 20:30:52 +00:00
|
|
|
GimpTool *tool = GIMP_TOOL (by_color_select);
|
|
|
|
|
2006-06-03 15:41:40 +00:00
|
|
|
gimp_tool_control_set_tool_cursor (tool->control, GIMP_TOOL_CURSOR_HAND);
|
2006-06-13 23:47:20 +00:00
|
|
|
}
|
|
|
|
|
2006-07-31 11:42:51 +00:00
|
|
|
static GimpChannel *
|
|
|
|
gimp_by_color_select_tool_get_mask (GimpRegionSelectTool *region_select,
|
|
|
|
GimpDisplay *display)
|
2006-06-13 23:47:20 +00:00
|
|
|
{
|
2006-09-05 18:25:31 +00:00
|
|
|
GimpTool *tool = GIMP_TOOL (region_select);
|
|
|
|
GimpSelectionOptions *options = GIMP_SELECTION_TOOL_GET_OPTIONS (tool);
|
2006-07-31 11:42:51 +00:00
|
|
|
GimpDrawable *drawable;
|
|
|
|
GimpPickable *pickable;
|
2007-05-02 17:15:03 +00:00
|
|
|
GimpRGB color;
|
2006-07-31 11:42:51 +00:00
|
|
|
gint x, y;
|
1997-11-24 22:05:25 +00:00
|
|
|
|
2006-07-31 11:42:51 +00:00
|
|
|
drawable = gimp_image_active_drawable (display->image);
|
1997-11-24 22:05:25 +00:00
|
|
|
|
2006-07-31 11:42:51 +00:00
|
|
|
x = region_select->x;
|
|
|
|
y = region_select->y;
|
2001-11-08 19:14:51 +00:00
|
|
|
|
2003-02-05 14:39:40 +00:00
|
|
|
if (! options->sample_merged)
|
2001-11-08 19:14:51 +00:00
|
|
|
{
|
|
|
|
gint off_x, off_y;
|
|
|
|
|
2006-07-31 11:42:51 +00:00
|
|
|
gimp_item_offsets (GIMP_ITEM (drawable), &off_x, &off_y);
|
2001-11-08 19:14:51 +00:00
|
|
|
|
2006-07-31 11:42:51 +00:00
|
|
|
x -= off_x;
|
|
|
|
y -= off_y;
|
1997-11-24 22:05:25 +00:00
|
|
|
|
2006-07-31 11:42:51 +00:00
|
|
|
pickable = GIMP_PICKABLE (drawable);
|
2001-11-08 19:14:51 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2006-07-31 11:42:51 +00:00
|
|
|
pickable = GIMP_PICKABLE (display->image->projection);
|
2001-11-08 19:14:51 +00:00
|
|
|
}
|
|
|
|
|
2006-07-31 11:42:51 +00:00
|
|
|
gimp_pickable_flush (pickable);
|
1997-11-24 22:05:25 +00:00
|
|
|
|
2007-05-02 17:15:03 +00:00
|
|
|
if (gimp_pickable_get_color_at (pickable, x, y, &color))
|
|
|
|
return gimp_image_contiguous_region_by_color (display->image, drawable,
|
|
|
|
options->sample_merged,
|
|
|
|
options->antialias,
|
|
|
|
options->threshold,
|
|
|
|
options->select_transparent,
|
|
|
|
options->select_criterion,
|
|
|
|
&color);
|
|
|
|
else
|
|
|
|
return NULL;
|
2006-06-13 23:47:20 +00:00
|
|
|
}
|