gimp/libgimp/gimpselection_pdb.c

702 lines
21 KiB
C
Raw Normal View History

/* LIBGIMP - The GIMP Library
* Copyright (C) 1995-2003 Peter Mattis and Spencer Kimball
Sven Neumann <sven@gimp.org> 2000-05-31 Michael Natterer <mitch@gimp.org> Sven Neumann <sven@gimp.org> * libgimp/Makefile.am * libgimp/gimpchannel_pdb.h * libgimp/gimpdisplay_pdb.h * libgimp/gimpdrawable_pdb.h * libgimp/gimpgradient_pdb.h * libgimp/gimphelp_pdb.h * libgimp/gimpimage_pdb.h * libgimp/gimplayer_pdb.h * libgimp/gimpparasite_pdb.h * libgimp/gimpselection_pdb.h * libgimp/gimpunit_pdb.h * libgimp/gimpdrawable.[ch] * libgimp/gimphelp.c * libgimp/gimppixelrgn.h * libgimp/gimptile.h: new files * libgimp/gimp.[ch] * libgimp/gimpchannel_pdb.c * libgimp/gimpdrawable_pdb.c * libgimp/gimpgradient_pdb.c * libgimp/gimppalette_pdb.c * libgimp/gimpselection_pdb.c * libgimp/gimphelp_pdb.c * libgimp/gimpimage_pdb.c * libgimp/gimplayer_pdb.c * libgimp/gimpgradientmenu.c * libgimp/gimpbrushmenu.c * libgimp/gimpmenu.[ch] * libgimp/gimppatternmenu.c * libgimp/gimppixelrgn.c * libgimp/gimptile.c: part III of the (final) libgimp cleanup Split gimp.h into a bunch of headers. More or less finished the task of moving PDB wrappers into separate files in preparation of the upcoming autogen-it-all-attack. * libgimp/gimpcompat.h: declared the following functions obsolete: gimp_[channel|layer]_[width|height] gimp_layer_[bpp|type] gimp_channel_get_[image|layer]_ID * libgimp/gimptypes.h: new file: GPlugInInfo GTile GDrawable GPixelRgn GParamColor GParamRegion GParamData GParamDef GParam: s/G/Gimp/ * app/gimphelp_cmds.c * app/plug_in_cmds.c * tools/pdbgen/pdb/gimphelp.pdb * tools/pdbgen/pdb/plug_in.pdb: changed help texts.
2000-05-31 14:15:06 +08:00
*
* gimpselection_pdb.c
*
* This library is free software: you can redistribute it and/or
1999-11-18 05:13:50 +08:00
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
Sven Neumann <sven@gimp.org> 2000-06-01 Michael Natterer <mitch@gimp.org> Sven Neumann <sven@gimp.org> Completed the new file structure. Yet only few of the _pdb.[ch] files are based upon generated code and nothing is really autogenerated... * app/Makefile.am * app/gdisplay_cmds.c -> app/display_cmds.c * app/gimage_cmds.c -> app/image_cmds.c * app/gimage_mask_cmds.c -> app/selection_cmds.c * app/internal_procs.c: related change * libgimp/Makefile.am * libgimp/gimp.h * libgimp/gimp_pdb.h * libgimp/gimpdisplay_pdb.[ch] * libgimp/gimpimage_pdb.[ch] * libgimp/gimpselection_pdb.[ch]: replaced with code based on files generated using pdbgen * libgimp/gimpchannelops_pdb.[ch] * libgimp/gimpcolor_pdb.[ch] * libgimp/gimpedit_pdb.[ch] * libgimp/gimpfloatingsel_pdb.[ch] * libgimp/gimpgimprc_pdb.[ch] * libgimp/gimptexttool_pdb.[ch] * libgimp/gimptools_pdb.[ch] * libgimp/gimpundo_pdb.[ch]: new files based on generated code * libgimp/gimpgradientselect.[ch] * libgimp/gimpimage.[ch] * libgimp/gimpselection.[ch]: new files wrapping around the autogenerated PDB wrappers as found in *_pdb.[ch]. This is necessary since the number of parameters or their order is different from the PDP calls. * plug-ins/common/CEL.c: plugged memleak * plug-ins/common/aa.c: removed compiler warning * tools/pdbgen/Makefile.am * tools/pdbgen/groups.pl * tools/pdbgen/pdb/gdisplay.pdb -> display.pdb * tools/pdbgen/pdb/gimage.pdb -> image.pdb * tools/pdbgen/pdb/gimage_mask.pdb -> selection.pdb * tools/pdbgen/pdb/channel_ops.pdb * tools/pdbgen/pdb/color.pdb * tools/pdbgen/pdb/edit.pdb * tools/pdbgen/pdb/floating_sel.pdb * tools/pdbgen/pdb/gimprc.pdb * tools/pdbgen/pdb/text_tool.pdb * tools/pdbgen/pdb/tools.pdb * tools/pdbgen/pdb/undo.pdb: made them create libgimp code
2000-06-01 20:20:13 +08:00
* This library 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
Sven Neumann <sven@gimp.org> 2000-06-01 Michael Natterer <mitch@gimp.org> Sven Neumann <sven@gimp.org> Completed the new file structure. Yet only few of the _pdb.[ch] files are based upon generated code and nothing is really autogenerated... * app/Makefile.am * app/gdisplay_cmds.c -> app/display_cmds.c * app/gimage_cmds.c -> app/image_cmds.c * app/gimage_mask_cmds.c -> app/selection_cmds.c * app/internal_procs.c: related change * libgimp/Makefile.am * libgimp/gimp.h * libgimp/gimp_pdb.h * libgimp/gimpdisplay_pdb.[ch] * libgimp/gimpimage_pdb.[ch] * libgimp/gimpselection_pdb.[ch]: replaced with code based on files generated using pdbgen * libgimp/gimpchannelops_pdb.[ch] * libgimp/gimpcolor_pdb.[ch] * libgimp/gimpedit_pdb.[ch] * libgimp/gimpfloatingsel_pdb.[ch] * libgimp/gimpgimprc_pdb.[ch] * libgimp/gimptexttool_pdb.[ch] * libgimp/gimptools_pdb.[ch] * libgimp/gimpundo_pdb.[ch]: new files based on generated code * libgimp/gimpgradientselect.[ch] * libgimp/gimpimage.[ch] * libgimp/gimpselection.[ch]: new files wrapping around the autogenerated PDB wrappers as found in *_pdb.[ch]. This is necessary since the number of parameters or their order is different from the PDP calls. * plug-ins/common/CEL.c: plugged memleak * plug-ins/common/aa.c: removed compiler warning * tools/pdbgen/Makefile.am * tools/pdbgen/groups.pl * tools/pdbgen/pdb/gdisplay.pdb -> display.pdb * tools/pdbgen/pdb/gimage.pdb -> image.pdb * tools/pdbgen/pdb/gimage_mask.pdb -> selection.pdb * tools/pdbgen/pdb/channel_ops.pdb * tools/pdbgen/pdb/color.pdb * tools/pdbgen/pdb/edit.pdb * tools/pdbgen/pdb/floating_sel.pdb * tools/pdbgen/pdb/gimprc.pdb * tools/pdbgen/pdb/text_tool.pdb * tools/pdbgen/pdb/tools.pdb * tools/pdbgen/pdb/undo.pdb: made them create libgimp code
2000-06-01 20:20:13 +08:00
* Lesser General Public License for more details.
*
1999-11-18 05:13:50 +08:00
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see
* <https://www.gnu.org/licenses/>.
*/
/* NOTE: This file is auto-generated by pdbgen.pl */
#include "config.h"
Sven Neumann <sven@gimp.org> 2000-06-01 Michael Natterer <mitch@gimp.org> Sven Neumann <sven@gimp.org> Completed the new file structure. Yet only few of the _pdb.[ch] files are based upon generated code and nothing is really autogenerated... * app/Makefile.am * app/gdisplay_cmds.c -> app/display_cmds.c * app/gimage_cmds.c -> app/image_cmds.c * app/gimage_mask_cmds.c -> app/selection_cmds.c * app/internal_procs.c: related change * libgimp/Makefile.am * libgimp/gimp.h * libgimp/gimp_pdb.h * libgimp/gimpdisplay_pdb.[ch] * libgimp/gimpimage_pdb.[ch] * libgimp/gimpselection_pdb.[ch]: replaced with code based on files generated using pdbgen * libgimp/gimpchannelops_pdb.[ch] * libgimp/gimpcolor_pdb.[ch] * libgimp/gimpedit_pdb.[ch] * libgimp/gimpfloatingsel_pdb.[ch] * libgimp/gimpgimprc_pdb.[ch] * libgimp/gimptexttool_pdb.[ch] * libgimp/gimptools_pdb.[ch] * libgimp/gimpundo_pdb.[ch]: new files based on generated code * libgimp/gimpgradientselect.[ch] * libgimp/gimpimage.[ch] * libgimp/gimpselection.[ch]: new files wrapping around the autogenerated PDB wrappers as found in *_pdb.[ch]. This is necessary since the number of parameters or their order is different from the PDP calls. * plug-ins/common/CEL.c: plugged memleak * plug-ins/common/aa.c: removed compiler warning * tools/pdbgen/Makefile.am * tools/pdbgen/groups.pl * tools/pdbgen/pdb/gdisplay.pdb -> display.pdb * tools/pdbgen/pdb/gimage.pdb -> image.pdb * tools/pdbgen/pdb/gimage_mask.pdb -> selection.pdb * tools/pdbgen/pdb/channel_ops.pdb * tools/pdbgen/pdb/color.pdb * tools/pdbgen/pdb/edit.pdb * tools/pdbgen/pdb/floating_sel.pdb * tools/pdbgen/pdb/gimprc.pdb * tools/pdbgen/pdb/text_tool.pdb * tools/pdbgen/pdb/tools.pdb * tools/pdbgen/pdb/undo.pdb: made them create libgimp code
2000-06-01 20:20:13 +08:00
#include "gimp.h"
Sven Neumann <sven@gimp.org> 2000-05-31 Michael Natterer <mitch@gimp.org> Sven Neumann <sven@gimp.org> Episode IV... * app/Makefile.am * app/message_cmds.c: new name * app/interface_cmds.c: removed * app/help_cmds.c: new name * app/gimphelp_cmds.c: removed * app/internal_procs.c * app/gimphelp_cmds.c * app/plug_in_cmds.c: moved gimp_plugin_help_register to plug_in_cmds.c, s/gimp_plugin_domain_add/gimp_plugin_domain_register/ * libgimp/Makefile.am * libgimp/gimp_pdb.h * libgimp/gimpfileops_pdb.[ch] * libgimp/gimpguides_pdb.[ch] * libgimp/gimpmessage_pdb.[ch] * libgimp/gimpprocedural_db_pdb.[ch] * libgimp/gimpplugin_pdb.[ch]: new files containing PDB wrappers moved out of libgimp/gimp.[ch] * libgimp/gimpchannel_pdb.c * libgimp/gimpdisplay_pdb.[ch] * libgimp/gimpdrawable_pdb.[ch] * libgimp/gimphelp_pdb.[ch] * libgimp/gimpimage_pdb.[ch] * libgimp/gimplayer_pdb.c * libgimp/gimpparasite_pdb.c * libgimp/gimpselection_pdb.c: various changes. * libgimp/gimpunit.c: new file * libgimp/gimpunit_pdb.[ch]: contains only PDB wrappers prefixed with "_" which are called from libgimp/gimpunit.c only. * libgimp/gimpunit.h: minor stuff * libgimp/gimpcompat.h: declared the following functions obsolete: gimp_query_database gimp_query_images * libgimp/gimp.[ch]: removed all PDB wrappers. * tools/pdbgen/Makefile.am * tools/pdbgen/groups.pl: changed * tools/pdbgen/lib.pl: tried to fix libgimp autogeneration and fixed just a few comments. * tools/pdbgen/pdb/interface.pdb * tools/pdbgen/pdb/gimphelp.pdb: removed * tools/pdbgen/pdb/help.pdb * tools/pdbgen/pdb/message.pdb: new names * plug-ins/script-fu/script-fu.c * plug-ins/perl/Gimp/Lib.xs: s/gimp_plugin_domain_add/gimp_plugin_domain_register/ 2000-05-31 Michael Natterer <mitch@gimp.org> * POTFILES.in: s/gimpunit_pdb/gimpunit/
2000-05-31 21:24:14 +08:00
/**
* SECTION: gimpselection
* @title: gimpselection
* @short_description: Functions for manipulating selections.
*
* Functions for manipulating selections.
**/
/**
* gimp_selection_bounds:
* @image: The image.
* @non_empty: (out): TRUE if there is a selection.
* @x1: (out): x coordinate of upper left corner of selection bounds.
* @y1: (out): y coordinate of upper left corner of selection bounds.
* @x2: (out): x coordinate of lower right corner of selection bounds.
* @y2: (out): y coordinate of lower right corner of 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 right 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).
*
* Returns: TRUE on success.
**/
gboolean
gimp_selection_bounds (GimpImage *image,
gboolean *non_empty,
gint *x1,
gint *y1,
gint *x2,
gint *y2)
{
GimpPDB *pdb = gimp_get_pdb ();
GimpValueArray *args;
GimpValueArray *return_vals;
gboolean success = TRUE;
args = gimp_value_array_new_from_types (NULL,
GIMP_TYPE_IMAGE_ID, gimp_image_get_id (image),
G_TYPE_NONE);
if (pdb)
return_vals = gimp_pdb_run_procedure_array (pdb,
"gimp-selection-bounds",
args);
else
return_vals = gimp_run_procedure_array ("gimp-selection-bounds",
args);
gimp_value_array_unref (args);
*non_empty = FALSE;
*x1 = 0;
*y1 = 0;
*x2 = 0;
*y2 = 0;
success = g_value_get_enum (gimp_value_array_index (return_vals, 0)) == GIMP_PDB_SUCCESS;
if (success)
{
*non_empty = g_value_get_boolean (gimp_value_array_index (return_vals, 1));
*x1 = g_value_get_int (gimp_value_array_index (return_vals, 2));
*y1 = g_value_get_int (gimp_value_array_index (return_vals, 3));
*x2 = g_value_get_int (gimp_value_array_index (return_vals, 4));
*y2 = g_value_get_int (gimp_value_array_index (return_vals, 5));
}
gimp_value_array_unref (return_vals);
return success;
}
/**
* gimp_selection_value:
* @image: The image.
* @x: x coordinate of value.
* @y: y coordinate of 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.
*
* Returns: Value of the selection.
**/
gint
gimp_selection_value (GimpImage *image,
gint x,
gint y)
{
GimpPDB *pdb = gimp_get_pdb ();
GimpValueArray *args;
GimpValueArray *return_vals;
gint value = 0;
args = gimp_value_array_new_from_types (NULL,
GIMP_TYPE_IMAGE_ID, gimp_image_get_id (image),
G_TYPE_INT, x,
G_TYPE_INT, y,
G_TYPE_NONE);
if (pdb)
return_vals = gimp_pdb_run_procedure_array (pdb,
"gimp-selection-value",
args);
else
return_vals = gimp_run_procedure_array ("gimp-selection-value",
args);
gimp_value_array_unref (args);
if (g_value_get_enum (gimp_value_array_index (return_vals, 0)) == GIMP_PDB_SUCCESS)
value = g_value_get_int (gimp_value_array_index (return_vals, 1));
gimp_value_array_unref (return_vals);
return value;
}
/**
* gimp_selection_is_empty:
* @image: The image.
*
* Determine whether the selection is empty.
*
2006-03-25 05:57:47 +08:00
* This procedure returns TRUE if the selection for the specified image
* is empty.
*
* Returns: Is the selection empty?
**/
Sven Neumann <sven@gimp.org> 2000-06-01 Michael Natterer <mitch@gimp.org> Sven Neumann <sven@gimp.org> Completed the new file structure. Yet only few of the _pdb.[ch] files are based upon generated code and nothing is really autogenerated... * app/Makefile.am * app/gdisplay_cmds.c -> app/display_cmds.c * app/gimage_cmds.c -> app/image_cmds.c * app/gimage_mask_cmds.c -> app/selection_cmds.c * app/internal_procs.c: related change * libgimp/Makefile.am * libgimp/gimp.h * libgimp/gimp_pdb.h * libgimp/gimpdisplay_pdb.[ch] * libgimp/gimpimage_pdb.[ch] * libgimp/gimpselection_pdb.[ch]: replaced with code based on files generated using pdbgen * libgimp/gimpchannelops_pdb.[ch] * libgimp/gimpcolor_pdb.[ch] * libgimp/gimpedit_pdb.[ch] * libgimp/gimpfloatingsel_pdb.[ch] * libgimp/gimpgimprc_pdb.[ch] * libgimp/gimptexttool_pdb.[ch] * libgimp/gimptools_pdb.[ch] * libgimp/gimpundo_pdb.[ch]: new files based on generated code * libgimp/gimpgradientselect.[ch] * libgimp/gimpimage.[ch] * libgimp/gimpselection.[ch]: new files wrapping around the autogenerated PDB wrappers as found in *_pdb.[ch]. This is necessary since the number of parameters or their order is different from the PDP calls. * plug-ins/common/CEL.c: plugged memleak * plug-ins/common/aa.c: removed compiler warning * tools/pdbgen/Makefile.am * tools/pdbgen/groups.pl * tools/pdbgen/pdb/gdisplay.pdb -> display.pdb * tools/pdbgen/pdb/gimage.pdb -> image.pdb * tools/pdbgen/pdb/gimage_mask.pdb -> selection.pdb * tools/pdbgen/pdb/channel_ops.pdb * tools/pdbgen/pdb/color.pdb * tools/pdbgen/pdb/edit.pdb * tools/pdbgen/pdb/floating_sel.pdb * tools/pdbgen/pdb/gimprc.pdb * tools/pdbgen/pdb/text_tool.pdb * tools/pdbgen/pdb/tools.pdb * tools/pdbgen/pdb/undo.pdb: made them create libgimp code
2000-06-01 20:20:13 +08:00
gboolean
gimp_selection_is_empty (GimpImage *image)
{
GimpPDB *pdb = gimp_get_pdb ();
GimpValueArray *args;
GimpValueArray *return_vals;
gboolean is_empty = FALSE;
args = gimp_value_array_new_from_types (NULL,
GIMP_TYPE_IMAGE_ID, gimp_image_get_id (image),
G_TYPE_NONE);
if (pdb)
return_vals = gimp_pdb_run_procedure_array (pdb,
"gimp-selection-is-empty",
args);
else
return_vals = gimp_run_procedure_array ("gimp-selection-is-empty",
args);
gimp_value_array_unref (args);
if (g_value_get_enum (gimp_value_array_index (return_vals, 0)) == GIMP_PDB_SUCCESS)
is_empty = g_value_get_boolean (gimp_value_array_index (return_vals, 1));
gimp_value_array_unref (return_vals);
Sven Neumann <sven@gimp.org> 2000-06-01 Michael Natterer <mitch@gimp.org> Sven Neumann <sven@gimp.org> Completed the new file structure. Yet only few of the _pdb.[ch] files are based upon generated code and nothing is really autogenerated... * app/Makefile.am * app/gdisplay_cmds.c -> app/display_cmds.c * app/gimage_cmds.c -> app/image_cmds.c * app/gimage_mask_cmds.c -> app/selection_cmds.c * app/internal_procs.c: related change * libgimp/Makefile.am * libgimp/gimp.h * libgimp/gimp_pdb.h * libgimp/gimpdisplay_pdb.[ch] * libgimp/gimpimage_pdb.[ch] * libgimp/gimpselection_pdb.[ch]: replaced with code based on files generated using pdbgen * libgimp/gimpchannelops_pdb.[ch] * libgimp/gimpcolor_pdb.[ch] * libgimp/gimpedit_pdb.[ch] * libgimp/gimpfloatingsel_pdb.[ch] * libgimp/gimpgimprc_pdb.[ch] * libgimp/gimptexttool_pdb.[ch] * libgimp/gimptools_pdb.[ch] * libgimp/gimpundo_pdb.[ch]: new files based on generated code * libgimp/gimpgradientselect.[ch] * libgimp/gimpimage.[ch] * libgimp/gimpselection.[ch]: new files wrapping around the autogenerated PDB wrappers as found in *_pdb.[ch]. This is necessary since the number of parameters or their order is different from the PDP calls. * plug-ins/common/CEL.c: plugged memleak * plug-ins/common/aa.c: removed compiler warning * tools/pdbgen/Makefile.am * tools/pdbgen/groups.pl * tools/pdbgen/pdb/gdisplay.pdb -> display.pdb * tools/pdbgen/pdb/gimage.pdb -> image.pdb * tools/pdbgen/pdb/gimage_mask.pdb -> selection.pdb * tools/pdbgen/pdb/channel_ops.pdb * tools/pdbgen/pdb/color.pdb * tools/pdbgen/pdb/edit.pdb * tools/pdbgen/pdb/floating_sel.pdb * tools/pdbgen/pdb/gimprc.pdb * tools/pdbgen/pdb/text_tool.pdb * tools/pdbgen/pdb/tools.pdb * tools/pdbgen/pdb/undo.pdb: made them create libgimp code
2000-06-01 20:20:13 +08:00
return is_empty;
}
/**
* gimp_selection_translate:
* @image: The image.
* @offx: x offset for translation.
* @offy: y offset for translation.
*
* 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.
*
* Returns: TRUE on success.
**/
gboolean
gimp_selection_translate (GimpImage *image,
gint offx,
gint offy)
{
GimpPDB *pdb = gimp_get_pdb ();
GimpValueArray *args;
GimpValueArray *return_vals;
gboolean success = TRUE;
args = gimp_value_array_new_from_types (NULL,
GIMP_TYPE_IMAGE_ID, gimp_image_get_id (image),
G_TYPE_INT, offx,
G_TYPE_INT, offy,
G_TYPE_NONE);
if (pdb)
return_vals = gimp_pdb_run_procedure_array (pdb,
"gimp-selection-translate",
args);
else
return_vals = gimp_run_procedure_array ("gimp-selection-translate",
args);
gimp_value_array_unref (args);
success = g_value_get_enum (gimp_value_array_index (return_vals, 0)) == GIMP_PDB_SUCCESS;
gimp_value_array_unref (return_vals);
return success;
}
/**
* _gimp_selection_float:
* @drawable_ID: The drawable from which to float selection.
* @offx: x offset for translation.
* @offy: y offset for translation.
*
* 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.
*
* Returns: The floated layer.
**/
Sven Neumann <sven@gimp.org> 2000-06-01 Michael Natterer <mitch@gimp.org> Sven Neumann <sven@gimp.org> Completed the new file structure. Yet only few of the _pdb.[ch] files are based upon generated code and nothing is really autogenerated... * app/Makefile.am * app/gdisplay_cmds.c -> app/display_cmds.c * app/gimage_cmds.c -> app/image_cmds.c * app/gimage_mask_cmds.c -> app/selection_cmds.c * app/internal_procs.c: related change * libgimp/Makefile.am * libgimp/gimp.h * libgimp/gimp_pdb.h * libgimp/gimpdisplay_pdb.[ch] * libgimp/gimpimage_pdb.[ch] * libgimp/gimpselection_pdb.[ch]: replaced with code based on files generated using pdbgen * libgimp/gimpchannelops_pdb.[ch] * libgimp/gimpcolor_pdb.[ch] * libgimp/gimpedit_pdb.[ch] * libgimp/gimpfloatingsel_pdb.[ch] * libgimp/gimpgimprc_pdb.[ch] * libgimp/gimptexttool_pdb.[ch] * libgimp/gimptools_pdb.[ch] * libgimp/gimpundo_pdb.[ch]: new files based on generated code * libgimp/gimpgradientselect.[ch] * libgimp/gimpimage.[ch] * libgimp/gimpselection.[ch]: new files wrapping around the autogenerated PDB wrappers as found in *_pdb.[ch]. This is necessary since the number of parameters or their order is different from the PDP calls. * plug-ins/common/CEL.c: plugged memleak * plug-ins/common/aa.c: removed compiler warning * tools/pdbgen/Makefile.am * tools/pdbgen/groups.pl * tools/pdbgen/pdb/gdisplay.pdb -> display.pdb * tools/pdbgen/pdb/gimage.pdb -> image.pdb * tools/pdbgen/pdb/gimage_mask.pdb -> selection.pdb * tools/pdbgen/pdb/channel_ops.pdb * tools/pdbgen/pdb/color.pdb * tools/pdbgen/pdb/edit.pdb * tools/pdbgen/pdb/floating_sel.pdb * tools/pdbgen/pdb/gimprc.pdb * tools/pdbgen/pdb/text_tool.pdb * tools/pdbgen/pdb/tools.pdb * tools/pdbgen/pdb/undo.pdb: made them create libgimp code
2000-06-01 20:20:13 +08:00
gint32
_gimp_selection_float (gint32 drawable_ID,
gint offx,
gint offy)
{
GimpPDB *pdb = gimp_get_pdb ();
GimpValueArray *args;
GimpValueArray *return_vals;
Sven Neumann <sven@gimp.org> 2000-06-01 Michael Natterer <mitch@gimp.org> Sven Neumann <sven@gimp.org> Completed the new file structure. Yet only few of the _pdb.[ch] files are based upon generated code and nothing is really autogenerated... * app/Makefile.am * app/gdisplay_cmds.c -> app/display_cmds.c * app/gimage_cmds.c -> app/image_cmds.c * app/gimage_mask_cmds.c -> app/selection_cmds.c * app/internal_procs.c: related change * libgimp/Makefile.am * libgimp/gimp.h * libgimp/gimp_pdb.h * libgimp/gimpdisplay_pdb.[ch] * libgimp/gimpimage_pdb.[ch] * libgimp/gimpselection_pdb.[ch]: replaced with code based on files generated using pdbgen * libgimp/gimpchannelops_pdb.[ch] * libgimp/gimpcolor_pdb.[ch] * libgimp/gimpedit_pdb.[ch] * libgimp/gimpfloatingsel_pdb.[ch] * libgimp/gimpgimprc_pdb.[ch] * libgimp/gimptexttool_pdb.[ch] * libgimp/gimptools_pdb.[ch] * libgimp/gimpundo_pdb.[ch]: new files based on generated code * libgimp/gimpgradientselect.[ch] * libgimp/gimpimage.[ch] * libgimp/gimpselection.[ch]: new files wrapping around the autogenerated PDB wrappers as found in *_pdb.[ch]. This is necessary since the number of parameters or their order is different from the PDP calls. * plug-ins/common/CEL.c: plugged memleak * plug-ins/common/aa.c: removed compiler warning * tools/pdbgen/Makefile.am * tools/pdbgen/groups.pl * tools/pdbgen/pdb/gdisplay.pdb -> display.pdb * tools/pdbgen/pdb/gimage.pdb -> image.pdb * tools/pdbgen/pdb/gimage_mask.pdb -> selection.pdb * tools/pdbgen/pdb/channel_ops.pdb * tools/pdbgen/pdb/color.pdb * tools/pdbgen/pdb/edit.pdb * tools/pdbgen/pdb/floating_sel.pdb * tools/pdbgen/pdb/gimprc.pdb * tools/pdbgen/pdb/text_tool.pdb * tools/pdbgen/pdb/tools.pdb * tools/pdbgen/pdb/undo.pdb: made them create libgimp code
2000-06-01 20:20:13 +08:00
gint32 layer_ID = -1;
args = gimp_value_array_new_from_types (NULL,
GIMP_TYPE_DRAWABLE_ID, drawable_ID,
G_TYPE_INT, offx,
G_TYPE_INT, offy,
G_TYPE_NONE);
Sven Neumann <sven@gimp.org> 2000-06-01 Michael Natterer <mitch@gimp.org> Sven Neumann <sven@gimp.org> Completed the new file structure. Yet only few of the _pdb.[ch] files are based upon generated code and nothing is really autogenerated... * app/Makefile.am * app/gdisplay_cmds.c -> app/display_cmds.c * app/gimage_cmds.c -> app/image_cmds.c * app/gimage_mask_cmds.c -> app/selection_cmds.c * app/internal_procs.c: related change * libgimp/Makefile.am * libgimp/gimp.h * libgimp/gimp_pdb.h * libgimp/gimpdisplay_pdb.[ch] * libgimp/gimpimage_pdb.[ch] * libgimp/gimpselection_pdb.[ch]: replaced with code based on files generated using pdbgen * libgimp/gimpchannelops_pdb.[ch] * libgimp/gimpcolor_pdb.[ch] * libgimp/gimpedit_pdb.[ch] * libgimp/gimpfloatingsel_pdb.[ch] * libgimp/gimpgimprc_pdb.[ch] * libgimp/gimptexttool_pdb.[ch] * libgimp/gimptools_pdb.[ch] * libgimp/gimpundo_pdb.[ch]: new files based on generated code * libgimp/gimpgradientselect.[ch] * libgimp/gimpimage.[ch] * libgimp/gimpselection.[ch]: new files wrapping around the autogenerated PDB wrappers as found in *_pdb.[ch]. This is necessary since the number of parameters or their order is different from the PDP calls. * plug-ins/common/CEL.c: plugged memleak * plug-ins/common/aa.c: removed compiler warning * tools/pdbgen/Makefile.am * tools/pdbgen/groups.pl * tools/pdbgen/pdb/gdisplay.pdb -> display.pdb * tools/pdbgen/pdb/gimage.pdb -> image.pdb * tools/pdbgen/pdb/gimage_mask.pdb -> selection.pdb * tools/pdbgen/pdb/channel_ops.pdb * tools/pdbgen/pdb/color.pdb * tools/pdbgen/pdb/edit.pdb * tools/pdbgen/pdb/floating_sel.pdb * tools/pdbgen/pdb/gimprc.pdb * tools/pdbgen/pdb/text_tool.pdb * tools/pdbgen/pdb/tools.pdb * tools/pdbgen/pdb/undo.pdb: made them create libgimp code
2000-06-01 20:20:13 +08:00
if (pdb)
return_vals = gimp_pdb_run_procedure_array (pdb,
"gimp-selection-float",
args);
else
return_vals = gimp_run_procedure_array ("gimp-selection-float",
args);
gimp_value_array_unref (args);
if (g_value_get_enum (gimp_value_array_index (return_vals, 0)) == GIMP_PDB_SUCCESS)
layer_ID = gimp_value_get_layer_id (gimp_value_array_index (return_vals, 1));
gimp_value_array_unref (return_vals);
Sven Neumann <sven@gimp.org> 2000-06-01 Michael Natterer <mitch@gimp.org> Sven Neumann <sven@gimp.org> Completed the new file structure. Yet only few of the _pdb.[ch] files are based upon generated code and nothing is really autogenerated... * app/Makefile.am * app/gdisplay_cmds.c -> app/display_cmds.c * app/gimage_cmds.c -> app/image_cmds.c * app/gimage_mask_cmds.c -> app/selection_cmds.c * app/internal_procs.c: related change * libgimp/Makefile.am * libgimp/gimp.h * libgimp/gimp_pdb.h * libgimp/gimpdisplay_pdb.[ch] * libgimp/gimpimage_pdb.[ch] * libgimp/gimpselection_pdb.[ch]: replaced with code based on files generated using pdbgen * libgimp/gimpchannelops_pdb.[ch] * libgimp/gimpcolor_pdb.[ch] * libgimp/gimpedit_pdb.[ch] * libgimp/gimpfloatingsel_pdb.[ch] * libgimp/gimpgimprc_pdb.[ch] * libgimp/gimptexttool_pdb.[ch] * libgimp/gimptools_pdb.[ch] * libgimp/gimpundo_pdb.[ch]: new files based on generated code * libgimp/gimpgradientselect.[ch] * libgimp/gimpimage.[ch] * libgimp/gimpselection.[ch]: new files wrapping around the autogenerated PDB wrappers as found in *_pdb.[ch]. This is necessary since the number of parameters or their order is different from the PDP calls. * plug-ins/common/CEL.c: plugged memleak * plug-ins/common/aa.c: removed compiler warning * tools/pdbgen/Makefile.am * tools/pdbgen/groups.pl * tools/pdbgen/pdb/gdisplay.pdb -> display.pdb * tools/pdbgen/pdb/gimage.pdb -> image.pdb * tools/pdbgen/pdb/gimage_mask.pdb -> selection.pdb * tools/pdbgen/pdb/channel_ops.pdb * tools/pdbgen/pdb/color.pdb * tools/pdbgen/pdb/edit.pdb * tools/pdbgen/pdb/floating_sel.pdb * tools/pdbgen/pdb/gimprc.pdb * tools/pdbgen/pdb/text_tool.pdb * tools/pdbgen/pdb/tools.pdb * tools/pdbgen/pdb/undo.pdb: made them create libgimp code
2000-06-01 20:20:13 +08:00
return layer_ID;
}
/**
* gimp_selection_invert:
* @image: The image.
*
* 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).
*
* Returns: TRUE on success.
**/
gboolean
gimp_selection_invert (GimpImage *image)
{
GimpPDB *pdb = gimp_get_pdb ();
GimpValueArray *args;
GimpValueArray *return_vals;
gboolean success = TRUE;
args = gimp_value_array_new_from_types (NULL,
GIMP_TYPE_IMAGE_ID, gimp_image_get_id (image),
G_TYPE_NONE);
if (pdb)
return_vals = gimp_pdb_run_procedure_array (pdb,
"gimp-selection-invert",
args);
else
return_vals = gimp_run_procedure_array ("gimp-selection-invert",
args);
gimp_value_array_unref (args);
success = g_value_get_enum (gimp_value_array_index (return_vals, 0)) == GIMP_PDB_SUCCESS;
gimp_value_array_unref (return_vals);
return success;
}
/**
* gimp_selection_sharpen:
* @image: The image.
*
* Sharpen the selection mask.
*
* This procedure sharpens the selection mask. For every pixel in the
* selection channel, if the value is &gt; 127, the new pixel is
* assigned a value of 255. This removes any \"anti-aliasing\" that
* might exist in the selection mask's boundary.
*
* Returns: TRUE on success.
**/
gboolean
gimp_selection_sharpen (GimpImage *image)
{
GimpPDB *pdb = gimp_get_pdb ();
GimpValueArray *args;
GimpValueArray *return_vals;
gboolean success = TRUE;
args = gimp_value_array_new_from_types (NULL,
GIMP_TYPE_IMAGE_ID, gimp_image_get_id (image),
G_TYPE_NONE);
if (pdb)
return_vals = gimp_pdb_run_procedure_array (pdb,
"gimp-selection-sharpen",
args);
else
return_vals = gimp_run_procedure_array ("gimp-selection-sharpen",
args);
gimp_value_array_unref (args);
success = g_value_get_enum (gimp_value_array_index (return_vals, 0)) == GIMP_PDB_SUCCESS;
gimp_value_array_unref (return_vals);
return success;
}
/**
* gimp_selection_all:
* @image: The image.
*
* 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.
*
* Returns: TRUE on success.
**/
gboolean
gimp_selection_all (GimpImage *image)
{
GimpPDB *pdb = gimp_get_pdb ();
GimpValueArray *args;
GimpValueArray *return_vals;
gboolean success = TRUE;
args = gimp_value_array_new_from_types (NULL,
GIMP_TYPE_IMAGE_ID, gimp_image_get_id (image),
G_TYPE_NONE);
if (pdb)
return_vals = gimp_pdb_run_procedure_array (pdb,
"gimp-selection-all",
args);
else
return_vals = gimp_run_procedure_array ("gimp-selection-all",
args);
gimp_value_array_unref (args);
success = g_value_get_enum (gimp_value_array_index (return_vals, 0)) == GIMP_PDB_SUCCESS;
gimp_value_array_unref (return_vals);
return success;
}
/**
* gimp_selection_none:
* @image: The image.
*
* Deselect the entire image.
*
* This procedure deselects the entire image. Every pixel in the
* selection channel is set to 0.
*
* Returns: TRUE on success.
**/
gboolean
gimp_selection_none (GimpImage *image)
{
GimpPDB *pdb = gimp_get_pdb ();
GimpValueArray *args;
GimpValueArray *return_vals;
gboolean success = TRUE;
args = gimp_value_array_new_from_types (NULL,
GIMP_TYPE_IMAGE_ID, gimp_image_get_id (image),
G_TYPE_NONE);
if (pdb)
return_vals = gimp_pdb_run_procedure_array (pdb,
"gimp-selection-none",
args);
else
return_vals = gimp_run_procedure_array ("gimp-selection-none",
args);
gimp_value_array_unref (args);
success = g_value_get_enum (gimp_value_array_index (return_vals, 0)) == GIMP_PDB_SUCCESS;
gimp_value_array_unref (return_vals);
return success;
}
/**
* gimp_selection_feather:
* @image: The image.
* @radius: Radius of feather (in pixels).
*
* Feather the image's selection
*
* This procedure feathers the selection. Feathering is implemented
* using a gaussian blur.
*
* Returns: TRUE on success.
**/
gboolean
gimp_selection_feather (GimpImage *image,
gdouble radius)
{
GimpPDB *pdb = gimp_get_pdb ();
GimpValueArray *args;
GimpValueArray *return_vals;
gboolean success = TRUE;
args = gimp_value_array_new_from_types (NULL,
GIMP_TYPE_IMAGE_ID, gimp_image_get_id (image),
G_TYPE_DOUBLE, radius,
G_TYPE_NONE);
if (pdb)
return_vals = gimp_pdb_run_procedure_array (pdb,
"gimp-selection-feather",
args);
else
return_vals = gimp_run_procedure_array ("gimp-selection-feather",
args);
gimp_value_array_unref (args);
success = g_value_get_enum (gimp_value_array_index (return_vals, 0)) == GIMP_PDB_SUCCESS;
gimp_value_array_unref (return_vals);
return success;
}
/**
* gimp_selection_border:
* @image: The image.
* @radius: Radius of border (in pixels).
*
* 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.
*
* Returns: TRUE on success.
**/
gboolean
gimp_selection_border (GimpImage *image,
gint radius)
{
GimpPDB *pdb = gimp_get_pdb ();
GimpValueArray *args;
GimpValueArray *return_vals;
gboolean success = TRUE;
args = gimp_value_array_new_from_types (NULL,
GIMP_TYPE_IMAGE_ID, gimp_image_get_id (image),
G_TYPE_INT, radius,
G_TYPE_NONE);
if (pdb)
return_vals = gimp_pdb_run_procedure_array (pdb,
"gimp-selection-border",
args);
else
return_vals = gimp_run_procedure_array ("gimp-selection-border",
args);
gimp_value_array_unref (args);
success = g_value_get_enum (gimp_value_array_index (return_vals, 0)) == GIMP_PDB_SUCCESS;
gimp_value_array_unref (return_vals);
return success;
}
/**
* gimp_selection_grow:
* @image: The image.
* @steps: Steps of grow (in pixels).
*
* Grow the image's selection
*
* This procedure grows the selection. Growing involves expanding the
* boundary in all directions by the specified pixel amount.
*
* Returns: TRUE on success.
**/
gboolean
gimp_selection_grow (GimpImage *image,
gint steps)
{
GimpPDB *pdb = gimp_get_pdb ();
GimpValueArray *args;
GimpValueArray *return_vals;
gboolean success = TRUE;
args = gimp_value_array_new_from_types (NULL,
GIMP_TYPE_IMAGE_ID, gimp_image_get_id (image),
G_TYPE_INT, steps,
G_TYPE_NONE);
if (pdb)
return_vals = gimp_pdb_run_procedure_array (pdb,
"gimp-selection-grow",
args);
else
return_vals = gimp_run_procedure_array ("gimp-selection-grow",
args);
gimp_value_array_unref (args);
success = g_value_get_enum (gimp_value_array_index (return_vals, 0)) == GIMP_PDB_SUCCESS;
gimp_value_array_unref (return_vals);
return success;
}
/**
* gimp_selection_shrink:
* @image: The image.
* @steps: Steps of shrink (in pixels).
*
* Shrink the image's selection
*
* This procedure shrinks the selection. Shrinking involves trimming
* the existing selection boundary on all sides by the specified number
* of pixels.
*
* Returns: TRUE on success.
**/
gboolean
gimp_selection_shrink (GimpImage *image,
gint steps)
{
GimpPDB *pdb = gimp_get_pdb ();
GimpValueArray *args;
GimpValueArray *return_vals;
gboolean success = TRUE;
args = gimp_value_array_new_from_types (NULL,
GIMP_TYPE_IMAGE_ID, gimp_image_get_id (image),
G_TYPE_INT, steps,
G_TYPE_NONE);
if (pdb)
return_vals = gimp_pdb_run_procedure_array (pdb,
"gimp-selection-shrink",
args);
else
return_vals = gimp_run_procedure_array ("gimp-selection-shrink",
args);
gimp_value_array_unref (args);
2016-01-25 02:24:51 +08:00
success = g_value_get_enum (gimp_value_array_index (return_vals, 0)) == GIMP_PDB_SUCCESS;
gimp_value_array_unref (return_vals);
2016-01-25 02:24:51 +08:00
return success;
}
/**
* gimp_selection_flood:
* @image: The image.
2016-01-25 02:24:51 +08:00
*
* Remove holes from the image's selection
2016-01-25 02:24:51 +08:00
*
* This procedure removes holes from the selection, that can come from
* selecting a patchy area with the Fuzzy Select Tool. In technical
* terms this procedure floods the selection. See the Algorithms page
* in the developer wiki for details.
2016-01-25 02:24:51 +08:00
*
* Returns: TRUE on success.
*
* Since: 2.10
**/
gboolean
gimp_selection_flood (GimpImage *image)
2016-01-25 02:24:51 +08:00
{
GimpPDB *pdb = gimp_get_pdb ();
GimpValueArray *args;
GimpValueArray *return_vals;
2016-01-25 02:24:51 +08:00
gboolean success = TRUE;
args = gimp_value_array_new_from_types (NULL,
GIMP_TYPE_IMAGE_ID, gimp_image_get_id (image),
G_TYPE_NONE);
if (pdb)
return_vals = gimp_pdb_run_procedure_array (pdb,
"gimp-selection-flood",
args);
else
return_vals = gimp_run_procedure_array ("gimp-selection-flood",
args);
gimp_value_array_unref (args);
2016-01-25 02:24:51 +08:00
success = g_value_get_enum (gimp_value_array_index (return_vals, 0)) == GIMP_PDB_SUCCESS;
gimp_value_array_unref (return_vals);
return success;
}
/**
* gimp_selection_save:
* @image: The image.
*
* 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.
*
* Returns: The new channel.
**/
gint32
gimp_selection_save (GimpImage *image)
{
GimpPDB *pdb = gimp_get_pdb ();
GimpValueArray *args;
GimpValueArray *return_vals;
gint32 channel_ID = -1;
args = gimp_value_array_new_from_types (NULL,
GIMP_TYPE_IMAGE_ID, gimp_image_get_id (image),
G_TYPE_NONE);
if (pdb)
return_vals = gimp_pdb_run_procedure_array (pdb,
"gimp-selection-save",
args);
else
return_vals = gimp_run_procedure_array ("gimp-selection-save",
args);
gimp_value_array_unref (args);
if (g_value_get_enum (gimp_value_array_index (return_vals, 0)) == GIMP_PDB_SUCCESS)
channel_ID = gimp_value_get_channel_id (gimp_value_array_index (return_vals, 1));
gimp_value_array_unref (return_vals);
return channel_ID;
}