gimp/app/pdb/selection_cmds.c

1157 lines
42 KiB
C

/* The GIMP -- an image manipulation program
* Copyright (C) 1995-2003 Spencer Kimball and Peter Mattis
*
* 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
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
/* NOTE: This file is autogenerated by pdbgen.pl. */
#include "config.h"
#include <glib-object.h>
#include "pdb-types.h"
#include "gimpargument.h"
#include "gimpprocedure.h"
#include "procedural_db.h"
#include "core/gimpparamspecs.h"
#include "core/gimpchannel-select.h"
#include "core/gimpchannel.h"
#include "core/gimpdrawable.h"
#include "core/gimpimage.h"
#include "core/gimplayer.h"
#include "core/gimppickable.h"
#include "core/gimpselection.h"
#include "gimp-intl.h"
static GimpProcedure selection_bounds_proc;
static GimpProcedure selection_value_proc;
static GimpProcedure selection_is_empty_proc;
static GimpProcedure selection_translate_proc;
static GimpProcedure selection_float_proc;
static GimpProcedure selection_invert_proc;
static GimpProcedure selection_sharpen_proc;
static GimpProcedure selection_all_proc;
static GimpProcedure selection_none_proc;
static GimpProcedure selection_feather_proc;
static GimpProcedure selection_border_proc;
static GimpProcedure selection_grow_proc;
static GimpProcedure selection_shrink_proc;
static GimpProcedure selection_layer_alpha_proc;
static GimpProcedure selection_load_proc;
static GimpProcedure selection_save_proc;
static GimpProcedure selection_combine_proc;
void
register_selection_procs (Gimp *gimp)
{
GimpProcedure *procedure;
/*
* selection_bounds
*/
procedure = gimp_procedure_init (&selection_bounds_proc, 1, 5);
gimp_procedure_add_argument (procedure,
GIMP_PDB_IMAGE,
gimp_param_spec_image_id ("image",
"image",
"The image",
gimp,
GIMP_PARAM_READWRITE));
gimp_procedure_add_return_value (procedure,
GIMP_PDB_INT32,
g_param_spec_boolean ("non-empty",
"non empty",
"TRUE if there is a selection",
FALSE,
GIMP_PARAM_READWRITE));
gimp_procedure_add_return_value (procedure,
GIMP_PDB_INT32,
g_param_spec_int ("x1",
"x1",
"x coordinate of upper left corner of selection bounds",
G_MININT32, G_MAXINT32, 0,
GIMP_PARAM_READWRITE));
gimp_procedure_add_return_value (procedure,
GIMP_PDB_INT32,
g_param_spec_int ("y1",
"y1",
"y coordinate of upper left corner of selection bounds",
G_MININT32, G_MAXINT32, 0,
GIMP_PARAM_READWRITE));
gimp_procedure_add_return_value (procedure,
GIMP_PDB_INT32,
g_param_spec_int ("x2",
"x2",
"x coordinate of lower right corner of selection bounds",
G_MININT32, G_MAXINT32, 0,
GIMP_PARAM_READWRITE));
gimp_procedure_add_return_value (procedure,
GIMP_PDB_INT32,
g_param_spec_int ("y2",
"y2",
"y coordinate of lower right corner of selection bounds",
G_MININT32, G_MAXINT32, 0,
GIMP_PARAM_READWRITE));
procedural_db_register (gimp, procedure);
/*
* selection_value
*/
procedure = gimp_procedure_init (&selection_value_proc, 3, 1);
gimp_procedure_add_argument (procedure,
GIMP_PDB_IMAGE,
gimp_param_spec_image_id ("image",
"image",
"The image",
gimp,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
GIMP_PDB_INT32,
g_param_spec_int ("x",
"x",
"x coordinate of value",
G_MININT32, G_MAXINT32, 0,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
GIMP_PDB_INT32,
g_param_spec_int ("y",
"y",
"y coordinate of value",
G_MININT32, G_MAXINT32, 0,
GIMP_PARAM_READWRITE));
gimp_procedure_add_return_value (procedure,
GIMP_PDB_INT32,
g_param_spec_int ("value",
"value",
"Value of the selection (0 <= value <= 255)",
0, 255, 0,
GIMP_PARAM_READWRITE));
procedural_db_register (gimp, procedure);
/*
* selection_is_empty
*/
procedure = gimp_procedure_init (&selection_is_empty_proc, 1, 1);
gimp_procedure_add_argument (procedure,
GIMP_PDB_IMAGE,
gimp_param_spec_image_id ("image",
"image",
"The image",
gimp,
GIMP_PARAM_READWRITE));
gimp_procedure_add_return_value (procedure,
GIMP_PDB_INT32,
g_param_spec_boolean ("is-empty",
"is empty",
"Is the selection empty?",
FALSE,
GIMP_PARAM_READWRITE));
procedural_db_register (gimp, procedure);
/*
* selection_translate
*/
procedure = gimp_procedure_init (&selection_translate_proc, 3, 0);
gimp_procedure_add_argument (procedure,
GIMP_PDB_IMAGE,
gimp_param_spec_image_id ("image",
"image",
"The image",
gimp,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
GIMP_PDB_INT32,
g_param_spec_int ("offx",
"offx",
"x offset for translation",
G_MININT32, G_MAXINT32, 0,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
GIMP_PDB_INT32,
g_param_spec_int ("offy",
"offy",
"y offset for translation",
G_MININT32, G_MAXINT32, 0,
GIMP_PARAM_READWRITE));
procedural_db_register (gimp, procedure);
/*
* selection_float
*/
procedure = gimp_procedure_init (&selection_float_proc, 3, 1);
gimp_procedure_add_argument (procedure,
GIMP_PDB_DRAWABLE,
gimp_param_spec_item_id ("drawable",
"drawable",
"The drawable from which to float selection",
gimp,
GIMP_TYPE_DRAWABLE,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
GIMP_PDB_INT32,
g_param_spec_int ("offx",
"offx",
"x offset for translation",
G_MININT32, G_MAXINT32, 0,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
GIMP_PDB_INT32,
g_param_spec_int ("offy",
"offy",
"y offset for translation",
G_MININT32, G_MAXINT32, 0,
GIMP_PARAM_READWRITE));
gimp_procedure_add_return_value (procedure,
GIMP_PDB_LAYER,
gimp_param_spec_item_id ("layer",
"layer",
"The floated layer",
gimp,
GIMP_TYPE_LAYER,
GIMP_PARAM_READWRITE));
procedural_db_register (gimp, procedure);
/*
* selection_invert
*/
procedure = gimp_procedure_init (&selection_invert_proc, 1, 0);
gimp_procedure_add_argument (procedure,
GIMP_PDB_IMAGE,
gimp_param_spec_image_id ("image",
"image",
"The image",
gimp,
GIMP_PARAM_READWRITE));
procedural_db_register (gimp, procedure);
/*
* selection_sharpen
*/
procedure = gimp_procedure_init (&selection_sharpen_proc, 1, 0);
gimp_procedure_add_argument (procedure,
GIMP_PDB_IMAGE,
gimp_param_spec_image_id ("image",
"image",
"The image",
gimp,
GIMP_PARAM_READWRITE));
procedural_db_register (gimp, procedure);
/*
* selection_all
*/
procedure = gimp_procedure_init (&selection_all_proc, 1, 0);
gimp_procedure_add_argument (procedure,
GIMP_PDB_IMAGE,
gimp_param_spec_image_id ("image",
"image",
"The image",
gimp,
GIMP_PARAM_READWRITE));
procedural_db_register (gimp, procedure);
/*
* selection_none
*/
procedure = gimp_procedure_init (&selection_none_proc, 1, 0);
gimp_procedure_add_argument (procedure,
GIMP_PDB_IMAGE,
gimp_param_spec_image_id ("image",
"image",
"The image",
gimp,
GIMP_PARAM_READWRITE));
procedural_db_register (gimp, procedure);
/*
* selection_feather
*/
procedure = gimp_procedure_init (&selection_feather_proc, 2, 0);
gimp_procedure_add_argument (procedure,
GIMP_PDB_IMAGE,
gimp_param_spec_image_id ("image",
"image",
"The image",
gimp,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
GIMP_PDB_FLOAT,
g_param_spec_double ("radius",
"radius",
"Radius of feather (in pixels)",
0, G_MAXDOUBLE, 0,
GIMP_PARAM_READWRITE));
procedural_db_register (gimp, procedure);
/*
* selection_border
*/
procedure = gimp_procedure_init (&selection_border_proc, 2, 0);
gimp_procedure_add_argument (procedure,
GIMP_PDB_IMAGE,
gimp_param_spec_image_id ("image",
"image",
"The image",
gimp,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
GIMP_PDB_INT32,
g_param_spec_int ("radius",
"radius",
"Radius of border (in pixels)",
0, G_MAXINT32, 0,
GIMP_PARAM_READWRITE));
procedural_db_register (gimp, procedure);
/*
* selection_grow
*/
procedure = gimp_procedure_init (&selection_grow_proc, 2, 0);
gimp_procedure_add_argument (procedure,
GIMP_PDB_IMAGE,
gimp_param_spec_image_id ("image",
"image",
"The image",
gimp,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
GIMP_PDB_INT32,
g_param_spec_int ("steps",
"steps",
"Steps of grow (in pixels)",
0, G_MAXINT32, 0,
GIMP_PARAM_READWRITE));
procedural_db_register (gimp, procedure);
/*
* selection_shrink
*/
procedure = gimp_procedure_init (&selection_shrink_proc, 2, 0);
gimp_procedure_add_argument (procedure,
GIMP_PDB_IMAGE,
gimp_param_spec_image_id ("image",
"image",
"The image",
gimp,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
GIMP_PDB_INT32,
g_param_spec_int ("steps",
"steps",
"Steps of shrink (in pixels)",
0, G_MAXINT32, 0,
GIMP_PARAM_READWRITE));
procedural_db_register (gimp, procedure);
/*
* selection_layer_alpha
*/
procedure = gimp_procedure_init (&selection_layer_alpha_proc, 1, 0);
gimp_procedure_add_argument (procedure,
GIMP_PDB_LAYER,
gimp_param_spec_item_id ("layer",
"layer",
"Layer with alpha",
gimp,
GIMP_TYPE_LAYER,
GIMP_PARAM_READWRITE));
procedural_db_register (gimp, procedure);
/*
* selection_load
*/
procedure = gimp_procedure_init (&selection_load_proc, 1, 0);
gimp_procedure_add_argument (procedure,
GIMP_PDB_CHANNEL,
gimp_param_spec_item_id ("channel",
"channel",
"The channel",
gimp,
GIMP_TYPE_CHANNEL,
GIMP_PARAM_READWRITE));
procedural_db_register (gimp, procedure);
/*
* selection_save
*/
procedure = gimp_procedure_init (&selection_save_proc, 1, 1);
gimp_procedure_add_argument (procedure,
GIMP_PDB_IMAGE,
gimp_param_spec_image_id ("image",
"image",
"The image",
gimp,
GIMP_PARAM_READWRITE));
gimp_procedure_add_return_value (procedure,
GIMP_PDB_CHANNEL,
gimp_param_spec_item_id ("channel",
"channel",
"The new channel",
gimp,
GIMP_TYPE_CHANNEL,
GIMP_PARAM_READWRITE));
procedural_db_register (gimp, procedure);
/*
* selection_combine
*/
procedure = gimp_procedure_init (&selection_combine_proc, 2, 0);
gimp_procedure_add_argument (procedure,
GIMP_PDB_CHANNEL,
gimp_param_spec_item_id ("channel",
"channel",
"The channel",
gimp,
GIMP_TYPE_CHANNEL,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
GIMP_PDB_INT32,
g_param_spec_enum ("operation",
"operation",
"The selection operation: { GIMP_CHANNEL_OP_ADD (0), GIMP_CHANNEL_OP_SUBTRACT (1), GIMP_CHANNEL_OP_REPLACE (2), GIMP_CHANNEL_OP_INTERSECT (3) }",
GIMP_TYPE_CHANNEL_OPS,
GIMP_CHANNEL_OP_ADD,
GIMP_PARAM_READWRITE));
procedural_db_register (gimp, procedure);
}
static Argument *
selection_bounds_invoker (GimpProcedure *procedure,
Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
Argument *args)
{
gboolean success = TRUE;
Argument *return_vals;
GimpImage *image;
gboolean non_empty = FALSE;
gint32 x1 = 0;
gint32 y1 = 0;
gint32 x2 = 0;
gint32 y2 = 0;
image = gimp_value_get_image (&args[0].value, gimp);
if (success)
{
non_empty = gimp_channel_bounds (gimp_image_get_mask (image),
&x1, &y1, &x2, &y2);
}
return_vals = gimp_procedure_get_return_values (procedure, success);
if (success)
{
g_value_set_boolean (&return_vals[1].value, non_empty);
g_value_set_int (&return_vals[2].value, x1);
g_value_set_int (&return_vals[3].value, y1);
g_value_set_int (&return_vals[4].value, x2);
g_value_set_int (&return_vals[5].value, y2);
}
return return_vals;
}
static GimpProcedure selection_bounds_proc =
{
TRUE, TRUE,
"gimp-selection-bounds",
"gimp-selection-bounds",
"Find the bounding box of the current selection.",
"This procedure returns whether there is a selection for the specified image. If there is one, the upper left and lower right corners of the bounding box are returned. These coordinates are relative to the image. Please note that the pixel specified by the lower righthand coordinate of the bounding box is not part of the selection. The selection ends at the upper left corner of this pixel. This means the width of the selection can be calculated as (x2 - x1), its height as (y2 - y1).",
"Spencer Kimball & Peter Mattis",
"Spencer Kimball & Peter Mattis",
"1995-1996",
NULL,
GIMP_INTERNAL,
0, NULL, 0, NULL,
{ { selection_bounds_invoker } }
};
static Argument *
selection_value_invoker (GimpProcedure *procedure,
Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
Argument *args)
{
gboolean success = TRUE;
Argument *return_vals;
GimpImage *image;
gint32 x;
gint32 y;
gint32 value = 0;
image = gimp_value_get_image (&args[0].value, gimp);
x = g_value_get_int (&args[1].value);
y = g_value_get_int (&args[2].value);
if (success)
{
value = gimp_pickable_get_opacity_at (GIMP_PICKABLE (gimp_image_get_mask (image)), x, y);
}
return_vals = gimp_procedure_get_return_values (procedure, success);
if (success)
g_value_set_int (&return_vals[1].value, value);
return return_vals;
}
static GimpProcedure selection_value_proc =
{
TRUE, TRUE,
"gimp-selection-value",
"gimp-selection-value",
"Find the value of the selection at the specified coordinates.",
"This procedure returns the value of the selection at the specified coordinates. If the coordinates lie out of bounds, 0 is returned.",
"Spencer Kimball & Peter Mattis",
"Spencer Kimball & Peter Mattis",
"1995-1996",
NULL,
GIMP_INTERNAL,
0, NULL, 0, NULL,
{ { selection_value_invoker } }
};
static Argument *
selection_is_empty_invoker (GimpProcedure *procedure,
Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
Argument *args)
{
gboolean success = TRUE;
Argument *return_vals;
GimpImage *image;
gboolean is_empty = FALSE;
image = gimp_value_get_image (&args[0].value, gimp);
if (success)
{
is_empty = gimp_channel_is_empty (gimp_image_get_mask (image));
}
return_vals = gimp_procedure_get_return_values (procedure, success);
if (success)
g_value_set_boolean (&return_vals[1].value, is_empty);
return return_vals;
}
static GimpProcedure selection_is_empty_proc =
{
TRUE, TRUE,
"gimp-selection-is-empty",
"gimp-selection-is-empty",
"Determine whether the selection is empty.",
"This procedure returns TRUE if the selection for the specified image is not empty.",
"Spencer Kimball & Peter Mattis",
"Spencer Kimball & Peter Mattis",
"1995-1996",
NULL,
GIMP_INTERNAL,
0, NULL, 0, NULL,
{ { selection_is_empty_invoker } }
};
static Argument *
selection_translate_invoker (GimpProcedure *procedure,
Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
Argument *args)
{
gboolean success = TRUE;
GimpImage *image;
gint32 offx;
gint32 offy;
image = gimp_value_get_image (&args[0].value, gimp);
offx = g_value_get_int (&args[1].value);
offy = g_value_get_int (&args[2].value);
if (success)
{
gimp_item_translate (GIMP_ITEM (gimp_image_get_mask (image)),
offx, offy, TRUE);
}
return gimp_procedure_get_return_values (procedure, success);
}
static GimpProcedure selection_translate_proc =
{
TRUE, TRUE,
"gimp-selection-translate",
"gimp-selection-translate",
"Translate the selection by the specified offsets.",
"This procedure actually translates the selection for the specified image by the specified offsets. Regions that are translated from beyond the bounds of the image are set to empty. Valid regions of the selection which are translated beyond the bounds of the image because of this call are lost.",
"Spencer Kimball & Peter Mattis",
"Spencer Kimball & Peter Mattis",
"1995-1996",
NULL,
GIMP_INTERNAL,
0, NULL, 0, NULL,
{ { selection_translate_invoker } }
};
static Argument *
selection_float_invoker (GimpProcedure *procedure,
Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
Argument *args)
{
gboolean success = TRUE;
Argument *return_vals;
GimpDrawable *drawable;
gint32 offx;
gint32 offy;
GimpLayer *layer = NULL;
drawable = (GimpDrawable *) gimp_value_get_item (&args[0].value, gimp, GIMP_TYPE_DRAWABLE);
offx = g_value_get_int (&args[1].value);
offy = g_value_get_int (&args[2].value);
if (success)
{
if (gimp_item_is_attached (GIMP_ITEM (drawable)))
{
GimpImage *image = gimp_item_get_image (GIMP_ITEM (drawable));
layer = gimp_selection_float (gimp_image_get_mask (image),
drawable, context, TRUE, offx, offy);
if (! layer)
success = FALSE;
}
else
success = FALSE;
}
return_vals = gimp_procedure_get_return_values (procedure, success);
if (success)
gimp_value_set_item (&return_vals[1].value, GIMP_ITEM (layer));
return return_vals;
}
static GimpProcedure selection_float_proc =
{
TRUE, TRUE,
"gimp-selection-float",
"gimp-selection-float",
"Float the selection from the specified drawable with initial offsets as specified.",
"This procedure determines the region of the specified drawable that lies beneath the current selection. The region is then cut from the drawable and the resulting data is made into a new layer which is instantiated as a floating selection. The offsets allow initial positioning of the new floating selection.",
"Spencer Kimball & Peter Mattis",
"Spencer Kimball & Peter Mattis",
"1995-1996",
NULL,
GIMP_INTERNAL,
0, NULL, 0, NULL,
{ { selection_float_invoker } }
};
static Argument *
selection_invert_invoker (GimpProcedure *procedure,
Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
Argument *args)
{
gboolean success = TRUE;
GimpImage *image;
image = gimp_value_get_image (&args[0].value, gimp);
if (success)
{
gimp_channel_invert (gimp_image_get_mask (image), TRUE);
}
return gimp_procedure_get_return_values (procedure, success);
}
static GimpProcedure selection_invert_proc =
{
TRUE, TRUE,
"gimp-selection-invert",
"gimp-selection-invert",
"Invert the selection mask.",
"This procedure inverts the selection mask. For every pixel in the selection channel, its new value is calculated as (255 - old_value).",
"Spencer Kimball & Peter Mattis",
"Spencer Kimball & Peter Mattis",
"1995-1996",
NULL,
GIMP_INTERNAL,
0, NULL, 0, NULL,
{ { selection_invert_invoker } }
};
static Argument *
selection_sharpen_invoker (GimpProcedure *procedure,
Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
Argument *args)
{
gboolean success = TRUE;
GimpImage *image;
image = gimp_value_get_image (&args[0].value, gimp);
if (success)
{
gimp_channel_sharpen (gimp_image_get_mask (image), TRUE);
}
return gimp_procedure_get_return_values (procedure, success);
}
static GimpProcedure selection_sharpen_proc =
{
TRUE, TRUE,
"gimp-selection-sharpen",
"gimp-selection-sharpen",
"Sharpen the selection mask.",
"This procedure sharpens the selection mask. For every pixel in the selection channel, if the value is > 0, the new pixel is assigned a value of 255. This removes any \"anti-aliasing\" that might exist in the selection mask's boundary.",
"Spencer Kimball & Peter Mattis",
"Spencer Kimball & Peter Mattis",
"1995-1996",
NULL,
GIMP_INTERNAL,
0, NULL, 0, NULL,
{ { selection_sharpen_invoker } }
};
static Argument *
selection_all_invoker (GimpProcedure *procedure,
Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
Argument *args)
{
gboolean success = TRUE;
GimpImage *image;
image = gimp_value_get_image (&args[0].value, gimp);
if (success)
{
gimp_channel_all (gimp_image_get_mask (image), TRUE);
}
return gimp_procedure_get_return_values (procedure, success);
}
static GimpProcedure selection_all_proc =
{
TRUE, TRUE,
"gimp-selection-all",
"gimp-selection-all",
"Select all of the image.",
"This procedure sets the selection mask to completely encompass the image. Every pixel in the selection channel is set to 255.",
"Spencer Kimball & Peter Mattis",
"Spencer Kimball & Peter Mattis",
"1995-1996",
NULL,
GIMP_INTERNAL,
0, NULL, 0, NULL,
{ { selection_all_invoker } }
};
static Argument *
selection_none_invoker (GimpProcedure *procedure,
Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
Argument *args)
{
gboolean success = TRUE;
GimpImage *image;
image = gimp_value_get_image (&args[0].value, gimp);
if (success)
{
gimp_channel_clear (gimp_image_get_mask (image), NULL, TRUE);
}
return gimp_procedure_get_return_values (procedure, success);
}
static GimpProcedure selection_none_proc =
{
TRUE, TRUE,
"gimp-selection-none",
"gimp-selection-none",
"Deselect the entire image.",
"This procedure deselects the entire image. Every pixel in the selection channel is set to 0.",
"Spencer Kimball & Peter Mattis",
"Spencer Kimball & Peter Mattis",
"1995-1996",
NULL,
GIMP_INTERNAL,
0, NULL, 0, NULL,
{ { selection_none_invoker } }
};
static Argument *
selection_feather_invoker (GimpProcedure *procedure,
Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
Argument *args)
{
gboolean success = TRUE;
GimpImage *image;
gdouble radius;
image = gimp_value_get_image (&args[0].value, gimp);
radius = g_value_get_double (&args[1].value);
if (success)
{
gimp_channel_feather (gimp_image_get_mask (image),
radius, radius, TRUE);
}
return gimp_procedure_get_return_values (procedure, success);
}
static GimpProcedure selection_feather_proc =
{
TRUE, TRUE,
"gimp-selection-feather",
"gimp-selection-feather",
"Feather the image's selection",
"This procedure feathers the selection. Feathering is implemented using a gaussian blur.",
"Spencer Kimball & Peter Mattis",
"Spencer Kimball & Peter Mattis",
"1995-1996",
NULL,
GIMP_INTERNAL,
0, NULL, 0, NULL,
{ { selection_feather_invoker } }
};
static Argument *
selection_border_invoker (GimpProcedure *procedure,
Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
Argument *args)
{
gboolean success = TRUE;
GimpImage *image;
gint32 radius;
image = gimp_value_get_image (&args[0].value, gimp);
radius = g_value_get_int (&args[1].value);
if (success)
{
gimp_channel_border (gimp_image_get_mask (image),
radius, radius, TRUE);
}
return gimp_procedure_get_return_values (procedure, success);
}
static GimpProcedure selection_border_proc =
{
TRUE, TRUE,
"gimp-selection-border",
"gimp-selection-border",
"Border the image's selection",
"This procedure borders the selection. Bordering creates a new selection which is defined along the boundary of the previous selection at every point within the specified radius.",
"Spencer Kimball & Peter Mattis",
"Spencer Kimball & Peter Mattis",
"1995-1996",
NULL,
GIMP_INTERNAL,
0, NULL, 0, NULL,
{ { selection_border_invoker } }
};
static Argument *
selection_grow_invoker (GimpProcedure *procedure,
Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
Argument *args)
{
gboolean success = TRUE;
GimpImage *image;
gint32 steps;
image = gimp_value_get_image (&args[0].value, gimp);
steps = g_value_get_int (&args[1].value);
if (success)
{
gimp_channel_grow (gimp_image_get_mask (image),
steps, steps, TRUE);
}
return gimp_procedure_get_return_values (procedure, success);
}
static GimpProcedure selection_grow_proc =
{
TRUE, TRUE,
"gimp-selection-grow",
"gimp-selection-grow",
"Grow the image's selection",
"This procedure grows the selection. Growing involves expanding the boundary in all directions by the specified pixel amount.",
"Spencer Kimball & Peter Mattis",
"Spencer Kimball & Peter Mattis",
"1995-1996",
NULL,
GIMP_INTERNAL,
0, NULL, 0, NULL,
{ { selection_grow_invoker } }
};
static Argument *
selection_shrink_invoker (GimpProcedure *procedure,
Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
Argument *args)
{
gboolean success = TRUE;
GimpImage *image;
gint32 steps;
image = gimp_value_get_image (&args[0].value, gimp);
steps = g_value_get_int (&args[1].value);
if (success)
{
gimp_channel_shrink (gimp_image_get_mask (image),
steps, steps, FALSE, TRUE);
}
return gimp_procedure_get_return_values (procedure, success);
}
static GimpProcedure selection_shrink_proc =
{
TRUE, TRUE,
"gimp-selection-shrink",
"gimp-selection-shrink",
"Shrink the image's selection",
"This procedure shrinks the selection. Shrinking invovles trimming the existing selection boundary on all sides by the specified number of pixels.",
"Spencer Kimball & Peter Mattis",
"Spencer Kimball & Peter Mattis",
"1995-1996",
NULL,
GIMP_INTERNAL,
0, NULL, 0, NULL,
{ { selection_shrink_invoker } }
};
static Argument *
selection_layer_alpha_invoker (GimpProcedure *procedure,
Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
Argument *args)
{
gboolean success = TRUE;
GimpLayer *layer;
layer = (GimpLayer *) gimp_value_get_item (&args[0].value, gimp, GIMP_TYPE_LAYER);
if (success)
{
GimpImage *image = gimp_item_get_image (GIMP_ITEM (layer));
gimp_channel_select_alpha (gimp_image_get_mask (image),
GIMP_DRAWABLE (layer),
GIMP_CHANNEL_OP_REPLACE, FALSE, 0.0, 0.0);
}
return gimp_procedure_get_return_values (procedure, success);
}
static GimpProcedure selection_layer_alpha_proc =
{
TRUE, TRUE,
"gimp-selection-layer-alpha",
"gimp-selection-layer-alpha",
"Transfer the specified layer's alpha channel to the selection mask.",
"This procedure requires a layer with an alpha channel. The alpha channel information is used to create a selection mask such that for any pixel in the image defined in the specified layer, that layer pixel's alpha value is transferred to the selection mask. If the layer is undefined at a particular image pixel, the associated selection mask value is set to 0.",
"Spencer Kimball & Peter Mattis",
"Spencer Kimball & Peter Mattis",
"1995-1996",
NULL,
GIMP_INTERNAL,
0, NULL, 0, NULL,
{ { selection_layer_alpha_invoker } }
};
static Argument *
selection_load_invoker (GimpProcedure *procedure,
Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
Argument *args)
{
gboolean success = TRUE;
GimpChannel *channel;
channel = (GimpChannel *) gimp_value_get_item (&args[0].value, gimp, GIMP_TYPE_CHANNEL);
if (success)
{
GimpImage *image;
gint off_x, off_y;
image = gimp_item_get_image (GIMP_ITEM (channel));
gimp_item_offsets (GIMP_ITEM (channel), &off_x, &off_y);
gimp_channel_select_channel (gimp_image_get_mask (image),
_("Channel to Selection"),
channel,
off_x, off_y,
GIMP_CHANNEL_OP_REPLACE,
FALSE, 0.0, 0.0);
}
return gimp_procedure_get_return_values (procedure, success);
}
static GimpProcedure selection_load_proc =
{
TRUE, TRUE,
"gimp-selection-load",
"gimp-selection-load",
"Transfer the specified channel to the selection mask.",
"This procedure loads the specified channel into the selection mask.",
"Spencer Kimball & Peter Mattis",
"Spencer Kimball & Peter Mattis",
"1995-1996",
NULL,
GIMP_INTERNAL,
0, NULL, 0, NULL,
{ { selection_load_invoker } }
};
static Argument *
selection_save_invoker (GimpProcedure *procedure,
Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
Argument *args)
{
gboolean success = TRUE;
Argument *return_vals;
GimpImage *image;
GimpChannel *channel = NULL;
image = gimp_value_get_image (&args[0].value, gimp);
if (success)
{
channel = gimp_selection_save (gimp_image_get_mask (image));
if (! channel)
success = FALSE;
}
return_vals = gimp_procedure_get_return_values (procedure, success);
if (success)
gimp_value_set_item (&return_vals[1].value, GIMP_ITEM (channel));
return return_vals;
}
static GimpProcedure selection_save_proc =
{
TRUE, TRUE,
"gimp-selection-save",
"gimp-selection-save",
"Copy the selection mask to a new channel.",
"This procedure copies the selection mask and stores the content in a new channel. The new channel is automatically inserted into the image's list of channels.",
"Spencer Kimball & Peter Mattis",
"Spencer Kimball & Peter Mattis",
"1995-1996",
NULL,
GIMP_INTERNAL,
0, NULL, 0, NULL,
{ { selection_save_invoker } }
};
static Argument *
selection_combine_invoker (GimpProcedure *procedure,
Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
Argument *args)
{
gboolean success = TRUE;
GimpChannel *channel;
gint32 operation;
channel = (GimpChannel *) gimp_value_get_item (&args[0].value, gimp, GIMP_TYPE_CHANNEL);
operation = g_value_get_enum (&args[1].value);
if (success)
{
GimpImage *image;
gint off_x, off_y;
image = gimp_item_get_image (GIMP_ITEM (channel));
gimp_item_offsets (GIMP_ITEM (channel), &off_x, &off_y);
gimp_channel_select_channel (gimp_image_get_mask (image),
_("Channel to Selection"),
channel,
off_x, off_y,
operation,
FALSE, 0.0, 0.0);
}
return gimp_procedure_get_return_values (procedure, success);
}
static GimpProcedure selection_combine_proc =
{
TRUE, TRUE,
"gimp-selection-combine",
"gimp-selection-combine",
"Combines the specified channel with the selection mask.",
"This procedure combines the specified channel into the selection mask.",
"Spencer Kimball & Peter Mattis",
"Spencer Kimball & Peter Mattis",
"1995-1996",
NULL,
GIMP_INTERNAL,
0, NULL, 0, NULL,
{ { selection_combine_invoker } }
};