diff --git a/ChangeLog b/ChangeLog index 2609bb3bb3..0418eac567 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +Sat Apr 24 18:36:04 PDT 1999 Manish Singh + + * app/gimage_mask_cmds.[ch]: pdbgenned, use header file + + * app/internal_procs.c: use pdbgen register for gimage mask funcs + + * app/Makefile.am: remove gimage_mask_cmds.h + Sat Apr 24 21:50:58 BST 1999 Adam D. Moss * app/edit_selection.c: Finished the opaque-move stuff... diff --git a/app/Makefile.am b/app/Makefile.am index 6788094f04..ec97817036 100644 --- a/app/Makefile.am +++ b/app/Makefile.am @@ -173,7 +173,6 @@ gimp_SOURCES = \ gimage_mask.c \ gimage_mask.h \ gimage_mask_cmds.c \ - gimage_mask_cmds.h \ gimpbrush.c \ gimpbrush.h \ gimpbrushgenerated.c \ diff --git a/app/gimage_mask_cmds.c b/app/gimage_mask_cmds.c index 2eee584246..8c41fadfed 100644 --- a/app/gimage_mask_cmds.c +++ b/app/gimage_mask_cmds.c @@ -1,5 +1,5 @@ /* The GIMP -- an image manipulation program - * Copyright (C) 1995 Spencer Kimball and Peter Mattis + * Copyright (C) 1995-1999 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 @@ -15,45 +15,76 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include -#include -#include "appenv.h" + +/* NOTE: This file is autogenerated by pdbgen.pl. */ + +#include "procedural_db.h" + +#include "channel.h" #include "drawable.h" -#include "general.h" -#include "gimage.h" #include "gimage_mask.h" -#include "gimage_mask_cmds.h" +#include "layer.h" -static int int_value; -static double fp_value; -static int success; -static Argument *return_args; +static ProcRecord selection_bounds_proc; +static ProcRecord selection_value_proc; +static ProcRecord selection_is_empty_proc; +static ProcRecord selection_translate_proc; +static ProcRecord selection_float_proc; +static ProcRecord selection_clear_proc; +static ProcRecord selection_invert_proc; +static ProcRecord selection_sharpen_proc; +static ProcRecord selection_all_proc; +static ProcRecord selection_none_proc; +static ProcRecord selection_feather_proc; +static ProcRecord selection_border_proc; +static ProcRecord selection_grow_proc; +static ProcRecord selection_shrink_proc; +static ProcRecord selection_layer_alpha_proc; +static ProcRecord selection_load_proc; +static ProcRecord selection_save_proc; - -/************************/ -/* GIMAGE_MASK_BOUNDS */ +void +register_gimage_mask_procs (void) +{ + procedural_db_register (&selection_bounds_proc); + procedural_db_register (&selection_value_proc); + procedural_db_register (&selection_is_empty_proc); + procedural_db_register (&selection_translate_proc); + procedural_db_register (&selection_float_proc); + procedural_db_register (&selection_clear_proc); + procedural_db_register (&selection_invert_proc); + procedural_db_register (&selection_sharpen_proc); + procedural_db_register (&selection_all_proc); + procedural_db_register (&selection_none_proc); + procedural_db_register (&selection_feather_proc); + procedural_db_register (&selection_border_proc); + procedural_db_register (&selection_grow_proc); + procedural_db_register (&selection_shrink_proc); + procedural_db_register (&selection_layer_alpha_proc); + procedural_db_register (&selection_load_proc); + procedural_db_register (&selection_save_proc); +} static Argument * -gimage_mask_bounds_invoker (Argument *args) +selection_bounds_invoker (Argument *args) { - GImage *gimage; - int x1, y1, x2, y2; - int non_empty; + gboolean success = TRUE; + Argument *return_args; + GimpImage *gimage; + gboolean non_empty = 0; + gint32 x1; + gint32 y1; + gint32 x2; + gint32 y2; - non_empty = FALSE; - - success = TRUE; - if (success) - { - int_value = args[0].value.pdb_int; - if ((gimage = gimage_get_ID (int_value)) == NULL) - success = FALSE; - } + gimage = pdb_id_to_image (args[0].value.pdb_int); + if (gimage == NULL) + success = FALSE; if (success) non_empty = gimage_mask_bounds (gimage, &x1, &y1, &x2, &y2); - return_args = procedural_db_return_args (&gimage_mask_bounds_proc, success); + return_args = procedural_db_return_args (&selection_bounds_proc, success); if (success) { @@ -67,1090 +98,874 @@ gimage_mask_bounds_invoker (Argument *args) return return_args; } -/* The procedure definition */ -ProcArg gimage_mask_bounds_args[] = +static ProcArg selection_bounds_inargs[] = { - { PDB_IMAGE, + { + PDB_IMAGE, "image", - "the image" + "The image" } }; -ProcArg gimage_mask_bounds_out_args[] = +static ProcArg selection_bounds_outargs[] = { - { PDB_INT32, - "non-empty", - "true if there is a selection" + { + PDB_INT32, + "non_empty", + "True if there is a selection" }, - { PDB_INT32, + { + PDB_INT32, "x1", "x coordinate of upper left corner of selection bounds" }, - { PDB_INT32, + { + PDB_INT32, "y1", "y coordinate of upper left corner of selection bounds" }, - { PDB_INT32, + { + PDB_INT32, "x2", "x coordinate of lower right corner of selection bounds" }, - { PDB_INT32, + { + PDB_INT32, "y2", "y coordinate of lower right corner of selection bounds" } }; -ProcRecord gimage_mask_bounds_proc = +static ProcRecord selection_bounds_proc = { "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.", + "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.", "Spencer Kimball & Peter Mattis", "Spencer Kimball & Peter Mattis", "1995-1996", PDB_INTERNAL, - - /* Input arguments */ 1, - gimage_mask_bounds_args, - - /* Output arguments */ + selection_bounds_inargs, 5, - gimage_mask_bounds_out_args, - - /* Exec method */ - { { gimage_mask_bounds_invoker } }, + selection_bounds_outargs, + { { selection_bounds_invoker } } }; - -/***********************/ -/* GIMAGE_MASK_VALUE */ - static Argument * -gimage_mask_value_invoker (Argument *args) +selection_value_invoker (Argument *args) { - GImage *gimage; - int x, y; - int value; + gboolean success = TRUE; + Argument *return_args; + GimpImage *gimage; + gint32 x; + gint32 y; - value = 0; + gimage = pdb_id_to_image (args[0].value.pdb_int); + if (gimage == NULL) + success = FALSE; - success = TRUE; - if (success) - { - int_value = args[0].value.pdb_int; - if ((gimage = gimage_get_ID (int_value)) == NULL) - success = FALSE; - } - if (success) - { - x = args[1].value.pdb_int; - y = args[2].value.pdb_int; - } - if (success) - value = gimage_mask_value (gimage, x, y); + x = args[1].value.pdb_int; - return_args = procedural_db_return_args (&gimage_mask_value_proc, success); + y = args[2].value.pdb_int; + + return_args = procedural_db_return_args (&selection_value_proc, success); if (success) - return_args[1].value.pdb_int = value; + return_args[1].value.pdb_int = gimage_mask_value (gimage, x, y); return return_args; } -/* The procedure definition */ -ProcArg gimage_mask_value_args[] = +static ProcArg selection_value_inargs[] = { - { PDB_IMAGE, + { + PDB_IMAGE, "image", - "the image" + "The image" }, - { PDB_INT32, + { + PDB_INT32, "x", "x coordinate of value" }, - { PDB_INT32, + { + PDB_INT32, "y", "y coordinate of value" } }; -ProcArg gimage_mask_value_out_args[] = +static ProcArg selection_value_outargs[] = { - { PDB_INT32, + { + PDB_INT32, "value", - "value of the selection: (0 <= value <= 255)" + "Value of the selection: (0 <= value <= 255)" } }; -ProcRecord gimage_mask_value_proc = +static ProcRecord selection_value_proc = { "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.", + "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", PDB_INTERNAL, - - /* Input arguments */ 3, - gimage_mask_value_args, - - /* Output arguments */ + selection_value_inargs, 1, - gimage_mask_value_out_args, - - /* Exec method */ - { { gimage_mask_value_invoker } }, + selection_value_outargs, + { { selection_value_invoker } } }; - -/**************************/ -/* GIMAGE_MASK_IS_EMPTY */ - static Argument * -gimage_mask_is_empty_invoker (Argument *args) +selection_is_empty_invoker (Argument *args) { - GImage *gimage; - int is_empty; + gboolean success = TRUE; + Argument *return_args; + GimpImage *gimage; - is_empty = TRUE; + gimage = pdb_id_to_image (args[0].value.pdb_int); + if (gimage == NULL) + success = FALSE; - success = TRUE; - if (success) - { - int_value = args[0].value.pdb_int; - if ((gimage = gimage_get_ID (int_value)) == NULL) - success = FALSE; - } - if (success) - is_empty = gimage_mask_is_empty (gimage); - - return_args = procedural_db_return_args (&gimage_mask_is_empty_proc, success); + return_args = procedural_db_return_args (&selection_is_empty_proc, success); if (success) - return_args[1].value.pdb_int = is_empty; + return_args[1].value.pdb_int = gimage_mask_is_empty (gimage); return return_args; } -/* The procedure definition */ -ProcArg gimage_mask_is_empty_args[] = +static ProcArg selection_is_empty_inargs[] = { - { PDB_IMAGE, + { + PDB_IMAGE, "image", - "the image" + "The image" } }; -ProcArg gimage_mask_is_empty_out_args[] = +static ProcArg selection_is_empty_outargs[] = { - { PDB_INT32, + { + PDB_INT32, "is_empty", - "is the selection empty?" + "Is the selection empty?" } }; -ProcRecord gimage_mask_is_empty_proc = +static ProcRecord selection_is_empty_proc = { "gimp_selection_is_empty", - "Determine whether the selection in empty", + "Determine whether the selection in empty.", "This procedure returns non-zero if the selection for the specified image is not empty.", "Spencer Kimball & Peter Mattis", "Spencer Kimball & Peter Mattis", "1995-1996", PDB_INTERNAL, - - /* Input arguments */ 1, - gimage_mask_is_empty_args, - - /* Output arguments */ + selection_is_empty_inargs, 1, - gimage_mask_is_empty_out_args, - - /* Exec method */ - { { gimage_mask_is_empty_invoker } }, + selection_is_empty_outargs, + { { selection_is_empty_invoker } } }; - -/***************************/ -/* GIMAGE_MASK_TRANSLATE */ - static Argument * -gimage_mask_translate_invoker (Argument *args) +selection_translate_invoker (Argument *args) { - GImage *gimage; - int offx, offy; + gboolean success = TRUE; + GimpImage *gimage; + gint32 offx; + gint32 offy; + + gimage = pdb_id_to_image (args[0].value.pdb_int); + if (gimage == NULL) + success = FALSE; + + offx = args[1].value.pdb_int; + + offy = args[2].value.pdb_int; - success = TRUE; - if (success) - { - int_value = args[0].value.pdb_int; - if ((gimage = gimage_get_ID (int_value)) == NULL) - success = FALSE; - } - if (success) - { - offx = args[1].value.pdb_int; - offy = args[2].value.pdb_int; - } if (success) gimage_mask_translate (gimage, offx, offy); - return procedural_db_return_args (&gimage_mask_translate_proc, success); + return procedural_db_return_args (&selection_translate_proc, success); } -/* The procedure definition */ -ProcArg gimage_mask_translate_args[] = +static ProcArg selection_translate_inargs[] = { - { PDB_IMAGE, + { + PDB_IMAGE, "image", - "the image" + "The image" }, - { PDB_INT32, - "offset_x", + { + PDB_INT32, + "offx", "x offset for translation" }, - { PDB_INT32, - "offset_y", + { + PDB_INT32, + "offy", "y offset for translation" } }; -ProcRecord gimage_mask_translate_proc = +static ProcRecord selection_translate_proc = { "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.", + "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", PDB_INTERNAL, - - /* Input arguments */ 3, - gimage_mask_translate_args, - - /* Output arguments */ + selection_translate_inargs, 0, NULL, - - /* Exec method */ - { { gimage_mask_translate_invoker } }, + { { selection_translate_invoker } } }; - -/***************************/ -/* GIMAGE_MASK_FLOAT */ - static Argument * -gimage_mask_float_invoker (Argument *args) +selection_float_invoker (Argument *args) { - GImage *gimage; + gboolean success = TRUE; + Argument *return_args; GimpDrawable *drawable; - int offx, offy; - Layer *layer; + gint32 offx; + gint32 offy; + GimpLayer *layer = NULL; + GimpImage *gimage; - layer = NULL; + drawable = gimp_drawable_get_ID (args[0].value.pdb_int); + if (drawable == NULL) + success = FALSE; + + offx = args[1].value.pdb_int; + + offy = args[2].value.pdb_int; - success = TRUE; if (success) { - int_value = args[0].value.pdb_int; - drawable = drawable_get_ID (int_value); - if (drawable == NULL) - { - success = FALSE; - gimage = NULL; - } - else - { - gimage = drawable_gimage (drawable); - } + gimage = drawable_gimage (drawable); + layer = gimage_mask_float (gimage, drawable, offx, offy); + success = layer != NULL; } - if (success) - { - offx = args[1].value.pdb_int; - offy = args[2].value.pdb_int; - } - if (success) - success = ((layer = gimage_mask_float (gimage, drawable, offx, offy)) != NULL); - return_args = procedural_db_return_args (&gimage_mask_float_proc, success); + return_args = procedural_db_return_args (&selection_float_proc, success); if (success) - return_args[1].value.pdb_int = drawable_ID (GIMP_DRAWABLE(layer)); + return_args[1].value.pdb_int = drawable_ID (GIMP_DRAWABLE (layer)); return return_args; } -/* The procedure definition */ -ProcArg gimage_mask_float_args[] = +static ProcArg selection_float_inargs[] = { - { PDB_DRAWABLE, + { + PDB_DRAWABLE, "drawable", - "the drawable from which to float selection" + "The drawable from which to float selection" }, - { PDB_INT32, - "offset_x", + { + PDB_INT32, + "offx", "x offset for translation" }, - { PDB_INT32, - "offset_y", + { + PDB_INT32, + "offy", "y offset for translation" } }; -ProcArg gimage_mask_float_out_args[] = +static ProcArg selection_float_outargs[] = { - { PDB_LAYER, + { + PDB_LAYER, "layer", - "the floated layer" + "The floated layer" } }; -ProcRecord gimage_mask_float_proc = +static ProcRecord selection_float_proc = { "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.", + "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", PDB_INTERNAL, - - /* Input arguments */ 3, - gimage_mask_float_args, - - /* Output arguments */ + selection_float_inargs, 1, - gimage_mask_float_out_args, - - /* Exec method */ - { { gimage_mask_float_invoker } }, + selection_float_outargs, + { { selection_float_invoker } } }; - -/***********************/ -/* GIMAGE_MASK_CLEAR */ - static Argument * -gimage_mask_clear_invoker (Argument *args) +selection_clear_invoker (Argument *args) { - GImage *gimage; + gboolean success = TRUE; + GimpImage *gimage; + + gimage = pdb_id_to_image (args[0].value.pdb_int); + if (gimage == NULL) + success = FALSE; - success = TRUE; - if (success) - { - int_value = args[0].value.pdb_int; - if ((gimage = gimage_get_ID (int_value)) == NULL) - success = FALSE; - } if (success) gimage_mask_clear (gimage); - return procedural_db_return_args (&gimage_mask_clear_proc, success); + return procedural_db_return_args (&selection_clear_proc, success); } -/* The procedure definition */ -ProcArg gimage_mask_clear_args[] = +static ProcArg selection_clear_inargs[] = { - { PDB_IMAGE, + { + PDB_IMAGE, "image", - "the image" + "The image" } }; -ProcRecord gimage_mask_clear_proc = +static ProcRecord selection_clear_proc = { "gimp_selection_clear", - "Set the selection to none, clearing all previous content", + "Set the selection to none, clearing all previous content.", "This procedure sets the selection mask to empty, assigning the value 0 to every pixel in the selection channel.", "Spencer Kimball & Peter Mattis", "Spencer Kimball & Peter Mattis", "1995-1996", PDB_INTERNAL, - - /* Input arguments */ 1, - gimage_mask_clear_args, - - /* Output arguments */ + selection_clear_inargs, 0, NULL, - - /* Exec method */ - { { gimage_mask_clear_invoker } }, + { { selection_clear_invoker } } }; - -/***********************/ -/* GIMAGE_MASK_INVERT */ - static Argument * -gimage_mask_invert_invoker (Argument *args) +selection_invert_invoker (Argument *args) { - GImage *gimage; + gboolean success = TRUE; + GimpImage *gimage; + + gimage = pdb_id_to_image (args[0].value.pdb_int); + if (gimage == NULL) + success = FALSE; - success = TRUE; - if (success) - { - int_value = args[0].value.pdb_int; - if ((gimage = gimage_get_ID (int_value)) == NULL) - success = FALSE; - } if (success) gimage_mask_invert (gimage); - return procedural_db_return_args (&gimage_mask_invert_proc, success); + return procedural_db_return_args (&selection_invert_proc, success); } -/* The procedure definition */ -ProcArg gimage_mask_invert_args[] = +static ProcArg selection_invert_inargs[] = { - { PDB_IMAGE, + { + PDB_IMAGE, "image", - "the image" + "The image" } }; -ProcRecord gimage_mask_invert_proc = +static ProcRecord selection_invert_proc = { "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).", + "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", PDB_INTERNAL, - - /* Input arguments */ 1, - gimage_mask_invert_args, - - /* Output arguments */ + selection_invert_inargs, 0, NULL, - - /* Exec method */ - { { gimage_mask_invert_invoker } }, + { { selection_invert_invoker } } }; - -/*************************/ -/* GIMAGE_MASK_SHARPEN */ - static Argument * -gimage_mask_sharpen_invoker (Argument *args) +selection_sharpen_invoker (Argument *args) { - GImage *gimage; + gboolean success = TRUE; + GimpImage *gimage; + + gimage = pdb_id_to_image (args[0].value.pdb_int); + if (gimage == NULL) + success = FALSE; - success = TRUE; - if (success) - { - int_value = args[0].value.pdb_int; - if ((gimage = gimage_get_ID (int_value)) == NULL) - success = FALSE; - } if (success) gimage_mask_sharpen (gimage); - return procedural_db_return_args (&gimage_mask_sharpen_proc, success); + return procedural_db_return_args (&selection_sharpen_proc, success); } -/* The procedure definition */ -ProcArg gimage_mask_sharpen_args[] = +static ProcArg selection_sharpen_inargs[] = { - { PDB_IMAGE, + { + PDB_IMAGE, "image", - "the image" + "The image" } }; -ProcRecord gimage_mask_sharpen_proc = +static ProcRecord selection_sharpen_proc = { "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.", + "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", PDB_INTERNAL, - - /* Input arguments */ 1, - gimage_mask_sharpen_args, - - /* Output arguments */ + selection_sharpen_inargs, 0, NULL, - - /* Exec method */ - { { gimage_mask_sharpen_invoker } }, + { { selection_sharpen_invoker } } }; - -/*********************/ -/* GIMAGE_MASK_ALL */ - static Argument * -gimage_mask_all_invoker (Argument *args) +selection_all_invoker (Argument *args) { - GImage *gimage; + gboolean success = TRUE; + GimpImage *gimage; + + gimage = pdb_id_to_image (args[0].value.pdb_int); + if (gimage == NULL) + success = FALSE; - success = TRUE; - if (success) - { - int_value = args[0].value.pdb_int; - if ((gimage = gimage_get_ID (int_value)) == NULL) - success = FALSE; - } if (success) gimage_mask_all (gimage); - return procedural_db_return_args (&gimage_mask_all_proc, success); + return procedural_db_return_args (&selection_all_proc, success); } -/* The procedure definition */ -ProcArg gimage_mask_all_args[] = +static ProcArg selection_all_inargs[] = { - { PDB_IMAGE, + { + PDB_IMAGE, "image", - "the image" + "The image" } }; -ProcRecord gimage_mask_all_proc = +static ProcRecord selection_all_proc = { "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.", + "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", PDB_INTERNAL, - - /* Input arguments */ 1, - gimage_mask_all_args, - - /* Output arguments */ + selection_all_inargs, 0, NULL, - - /* Exec method */ - { { gimage_mask_all_invoker } }, + { { selection_all_invoker } } }; - -/*********************/ -/* GIMAGE_MASK_NONE */ - static Argument * -gimage_mask_none_invoker (Argument *args) +selection_none_invoker (Argument *args) { - GImage *gimage; + gboolean success = TRUE; + GimpImage *gimage; + + gimage = pdb_id_to_image (args[0].value.pdb_int); + if (gimage == NULL) + success = FALSE; - success = TRUE; - if (success) - { - int_value = args[0].value.pdb_int; - if ((gimage = gimage_get_ID (int_value)) == NULL) - success = FALSE; - } if (success) gimage_mask_none (gimage); - return procedural_db_return_args (&gimage_mask_none_proc, success); + return procedural_db_return_args (&selection_none_proc, success); } -/* The procedure definition */ -ProcArg gimage_mask_none_args[] = +static ProcArg selection_none_inargs[] = { - { PDB_IMAGE, + { + PDB_IMAGE, "image", - "the image" + "The image" } }; -ProcRecord gimage_mask_none_proc = +static ProcRecord selection_none_proc = { "gimp_selection_none", - "Deselect the entire image", - "This procedure deselects the entire image. Every pixel in the selection channel is set to 0.", + "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", PDB_INTERNAL, - - /* Input arguments */ 1, - gimage_mask_none_args, - - /* Output arguments */ + selection_none_inargs, 0, NULL, - - /* Exec method */ - { { gimage_mask_none_invoker } }, + { { selection_none_invoker } } }; - -/************************/ -/* GIMAGE_MASK_FEATHER */ - static Argument * -gimage_mask_feather_invoker (Argument *args) +selection_feather_invoker (Argument *args) { - GImage *gimage; - double radius; + gboolean success = TRUE; + GimpImage *gimage; + gdouble radius; - radius = 0.0; + gimage = pdb_id_to_image (args[0].value.pdb_int); + if (gimage == NULL) + success = FALSE; + + radius = args[1].value.pdb_float; + if (radius <= 0.0) + success = FALSE; - success = TRUE; - if (success) - { - int_value = args[0].value.pdb_int; - if ((gimage = gimage_get_ID (int_value)) == NULL) - success = FALSE; - } - if (success) - { - fp_value = args[1].value.pdb_float; - if (fp_value > 0) - radius = fp_value; - } if (success) gimage_mask_feather (gimage, radius); - return procedural_db_return_args (&gimage_mask_feather_proc, success); + return procedural_db_return_args (&selection_feather_proc, success); } -/* The procedure definition */ -ProcArg gimage_mask_feather_args[] = +static ProcArg selection_feather_inargs[] = { - { PDB_IMAGE, + { + PDB_IMAGE, "image", - "the image" + "The image" }, - { PDB_FLOAT, + { + PDB_FLOAT, "radius", - "radius of feather (in pixels)" + "Radius of feather (in pixels)" } }; -ProcRecord gimage_mask_feather_proc = +static ProcRecord selection_feather_proc = { "gimp_selection_feather", "Feather the image's selection", - "This procedure feathers the selection. Feathering is implemented using a gaussian blur.", + "This procedure feathers the selection. Feathering is implemented using a gaussian blur.", "Spencer Kimball & Peter Mattis", "Spencer Kimball & Peter Mattis", "1995-1996", PDB_INTERNAL, - - /* Input arguments */ 2, - gimage_mask_feather_args, - - /* Output arguments */ + selection_feather_inargs, 0, NULL, - - /* Exec method */ - { { gimage_mask_feather_invoker } }, + { { selection_feather_invoker } } }; - -/***********************/ -/* GIMAGE_MASK_BORDER */ - static Argument * -gimage_mask_border_invoker (Argument *args) +selection_border_invoker (Argument *args) { - GImage *gimage; - int radius; + gboolean success = TRUE; + GimpImage *gimage; + gint32 radius; - radius = 0; + gimage = pdb_id_to_image (args[0].value.pdb_int); + if (gimage == NULL) + success = FALSE; + + radius = args[1].value.pdb_int; + if (radius <= 0) + success = FALSE; - success = TRUE; - if (success) - { - int_value = args[0].value.pdb_int; - if ((gimage = gimage_get_ID (int_value)) == NULL) - success = FALSE; - } - if (success) - { - int_value = args[1].value.pdb_int; - if (int_value > 0) - radius = int_value; - } if (success) gimage_mask_border (gimage, radius); - return procedural_db_return_args (&gimage_mask_border_proc, success); + return procedural_db_return_args (&selection_border_proc, success); } -/* The procedure definition */ -ProcArg gimage_mask_border_args[] = +static ProcArg selection_border_inargs[] = { - { PDB_IMAGE, + { + PDB_IMAGE, "image", - "the image" + "The image" }, - { PDB_INT32, + { + PDB_INT32, "radius", - "radius of border (pixels)" + "Radius of border (in pixels)" } }; -ProcRecord gimage_mask_border_proc = +static ProcRecord selection_border_proc = { "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.", + "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", PDB_INTERNAL, - - /* Input arguments */ 2, - gimage_mask_border_args, - - /* Output arguments */ + selection_border_inargs, 0, NULL, - - /* Exec method */ - { { gimage_mask_border_invoker } }, + { { selection_border_invoker } } }; - -/***********************/ -/* GIMAGE_MASK_GROW */ - static Argument * -gimage_mask_grow_invoker (Argument *args) +selection_grow_invoker (Argument *args) { - GImage *gimage; - int steps = 0; + gboolean success = TRUE; + GimpImage *gimage; + gint32 steps; + + gimage = pdb_id_to_image (args[0].value.pdb_int); + if (gimage == NULL) + success = FALSE; + + steps = args[1].value.pdb_int; + if (steps <= 0) + success = FALSE; - success = TRUE; - if (success) - { - int_value = args[0].value.pdb_int; - if ((gimage = gimage_get_ID (int_value)) == NULL) - success = FALSE; - } - if (success) - { - int_value = args[1].value.pdb_int; - if (int_value > 0) - steps = int_value; - } if (success) gimage_mask_grow (gimage, steps); - return procedural_db_return_args (&gimage_mask_grow_proc, success); + return procedural_db_return_args (&selection_grow_proc, success); } -/* The procedure definition */ -ProcArg gimage_mask_grow_args[] = +static ProcArg selection_grow_inargs[] = { - { PDB_IMAGE, + { + PDB_IMAGE, "image", - "the image" + "The image" }, - { PDB_INT32, + { + PDB_INT32, "steps", - "steps of grow (pixels)" + "Steps of grow (in pixels)" } }; -ProcRecord gimage_mask_grow_proc = +static ProcRecord selection_grow_proc = { "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.", + "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", PDB_INTERNAL, - - /* Input arguments */ 2, - gimage_mask_grow_args, - - /* Output arguments */ + selection_grow_inargs, 0, NULL, - - /* Exec method */ - { { gimage_mask_grow_invoker } }, + { { selection_grow_invoker } } }; - -/***********************/ -/* GIMAGE_MASK_SHRINK */ - static Argument * -gimage_mask_shrink_invoker (Argument *args) +selection_shrink_invoker (Argument *args) { - GImage *gimage; - int steps = 0; + gboolean success = TRUE; + GimpImage *gimage; + gint32 radius; - success = TRUE; - if (success) - { - int_value = args[0].value.pdb_int; - if ((gimage = gimage_get_ID (int_value)) == NULL) - success = FALSE; - } - if (success) - { - int_value = args[1].value.pdb_int; - if (int_value < 0) - success = FALSE; - else - steps = int_value; - } - if (success) - gimage_mask_shrink (gimage, steps); + gimage = pdb_id_to_image (args[0].value.pdb_int); + if (gimage == NULL) + success = FALSE; - return procedural_db_return_args (&gimage_mask_shrink_proc, success); + radius = args[1].value.pdb_int; + if (radius <= 0) + success = FALSE; + + if (success) + gimage_mask_shrink (gimage, radius); + + return procedural_db_return_args (&selection_shrink_proc, success); } -/* The procedure definition */ -ProcArg gimage_mask_shrink_args[] = +static ProcArg selection_shrink_inargs[] = { - { PDB_IMAGE, + { + PDB_IMAGE, "image", - "the image" + "The image" }, - { PDB_INT32, + { + PDB_INT32, "radius", - "radius of shrink (pixels)" + "Radius of shrink (in pixels)" } }; -ProcRecord gimage_mask_shrink_proc = +static ProcRecord selection_shrink_proc = { "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.", + "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", PDB_INTERNAL, - - /* Input arguments */ 2, - gimage_mask_shrink_args, - - /* Output arguments */ + selection_shrink_inargs, 0, NULL, - - /* Exec method */ - { { gimage_mask_shrink_invoker } }, + { { selection_shrink_invoker } } }; - -/****************************/ -/* GIMAGE_MASK_LAYER_ALPHA */ - static Argument * -gimage_mask_layer_alpha_invoker (Argument *args) +selection_layer_alpha_invoker (Argument *args) { - GImage *gimage; - Layer *layer; + gboolean success = TRUE; + GimpLayer *layer; + GimpImage *gimage; + + layer = layer_get_ID (args[0].value.pdb_int); + if (layer == NULL) + success = FALSE; - success = TRUE; if (success) { - int_value = args[0].value.pdb_int; - if ((layer = layer_get_ID (int_value)) == NULL) - { - success = FALSE; - gimage = NULL; - } - else - { - gimage = drawable_gimage (GIMP_DRAWABLE(layer)); - } + gimage = drawable_gimage (GIMP_DRAWABLE (layer)); + gimage_mask_layer_alpha (gimage, layer); } - if (success) - gimage_mask_layer_alpha (gimage, layer); - return procedural_db_return_args (&gimage_mask_layer_alpha_proc, success); + return procedural_db_return_args (&selection_layer_alpha_proc, success); } -/* The procedure definition */ -ProcArg gimage_mask_layer_alpha_args[] = +static ProcArg selection_layer_alpha_inargs[] = { - { PDB_LAYER, + { + PDB_LAYER, "layer", - "layer with alpha" + "Layer with alpha" } }; -ProcRecord gimage_mask_layer_alpha_proc = +static ProcRecord selection_layer_alpha_proc = { "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.", + "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", PDB_INTERNAL, - - /* Input arguments */ 1, - gimage_mask_layer_alpha_args, - - /* Output arguments */ + selection_layer_alpha_inargs, 0, NULL, - - /* Exec method */ - { { gimage_mask_layer_alpha_invoker } }, + { { selection_layer_alpha_invoker } } }; - -/**********************/ -/* GIMAGE_MASK_LOAD */ - static Argument * -gimage_mask_load_invoker (Argument *args) +selection_load_invoker (Argument *args) { - GImage *gimage; + gboolean success = TRUE; Channel *channel; + GimpImage *gimage; + + channel = channel_get_ID (args[0].value.pdb_int); + if (channel == NULL) + success = FALSE; - success = TRUE; if (success) { - int_value = args[0].value.pdb_int; - if ((channel = channel_get_ID (int_value)) == NULL) - { - success = FALSE; - gimage = NULL; - } + gimage = drawable_gimage (GIMP_DRAWABLE (channel)); + + if (drawable_width (GIMP_DRAWABLE (channel)) == gimage->width && + drawable_height (GIMP_DRAWABLE (channel)) == gimage->height) + gimage_mask_load (gimage, channel); else - { - gimage = drawable_gimage (GIMP_DRAWABLE(channel)); - success = (drawable_width (GIMP_DRAWABLE(channel)) == gimage->width && - drawable_height (GIMP_DRAWABLE(channel)) == gimage->height); - } - } - - if (success) - gimage_mask_load (gimage, channel); - - return procedural_db_return_args (&gimage_mask_load_proc, success); -} - -/* The procedure definition */ -ProcArg gimage_mask_load_args[] = -{ - { PDB_CHANNEL, - "channel", - "the channel" - } -}; - -ProcRecord gimage_mask_load_proc = -{ - "gimp_selection_load", - "Transfer the specified channel to the selection mask", - "This procedure loads the specified channel into the selection mask. This essentially involves a copy of the channel's content in to the selection mask. Therefore, the channel must have the same width and height of the image, or an error is returned.", - "Spencer Kimball & Peter Mattis", - "Spencer Kimball & Peter Mattis", - "1995-1996", - PDB_INTERNAL, - - /* Input arguments */ - 1, - gimage_mask_load_args, - - /* Output arguments */ - 0, - NULL, - - /* Exec method */ - { { gimage_mask_load_invoker } }, -}; - - -/**********************/ -/* GIMAGE_MASK_SAVE */ - -static Argument * -gimage_mask_save_invoker (Argument *args) -{ - GImage *gimage; - Channel *channel; - - channel = NULL; - - success = TRUE; - if (success) - { - int_value = args[0].value.pdb_int; - if ((gimage = gimage_get_ID (int_value)) == NULL) success = FALSE; } - if (success) - success = ((channel = gimage_mask_save (gimage)) != NULL); + return procedural_db_return_args (&selection_load_proc, success); +} - return_args = procedural_db_return_args (&gimage_mask_save_proc, success); +static ProcArg selection_load_inargs[] = +{ + { + PDB_CHANNEL, + "channel", + "The channel" + } +}; + +static ProcRecord selection_load_proc = +{ + "gimp_selection_load", + "Transfer the specified channel to the selection mask.", + "This procedure loads the specified channel into the selection mask. This essentially involves a copy of the channel's content in to the selection mask. Therefore, the channel must have the same width and height of the image, or an error is returned.", + "Spencer Kimball & Peter Mattis", + "Spencer Kimball & Peter Mattis", + "1995-1996", + PDB_INTERNAL, + 1, + selection_load_inargs, + 0, + NULL, + { { selection_load_invoker } } +}; + +static Argument * +selection_save_invoker (Argument *args) +{ + gboolean success = TRUE; + Argument *return_args; + GimpImage *gimage; + Channel *channel = NULL; + + gimage = pdb_id_to_image (args[0].value.pdb_int); + if (gimage == NULL) + success = FALSE; if (success) - return_args[1].value.pdb_int = drawable_ID (GIMP_DRAWABLE(channel)); + success = (channel = gimage_mask_save (gimage)) != NULL; + + return_args = procedural_db_return_args (&selection_save_proc, success); + + if (success) + return_args[1].value.pdb_int = drawable_ID (GIMP_DRAWABLE (channel)); return return_args; } -/* The procedure definition */ -ProcArg gimage_mask_save_args[] = +static ProcArg selection_save_inargs[] = { - { PDB_IMAGE, + { + PDB_IMAGE, "image", - "the image" + "The image" } }; -ProcArg gimage_mask_save_out_args[] = +static ProcArg selection_save_outargs[] = { - { PDB_CHANNEL, + { + PDB_CHANNEL, "channel", - "the new channel" + "The new channel" } }; -ProcRecord gimage_mask_save_proc = +static ProcRecord selection_save_proc = { "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.", + "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", PDB_INTERNAL, - - /* Input arguments */ 1, - gimage_mask_save_args, - - /* Output arguments */ + selection_save_inargs, 1, - gimage_mask_save_out_args, - - /* Exec method */ - { { gimage_mask_save_invoker } }, + selection_save_outargs, + { { selection_save_invoker } } }; diff --git a/app/gimage_mask_cmds.h b/app/gimage_mask_cmds.h deleted file mode 100644 index f8fcb309ba..0000000000 --- a/app/gimage_mask_cmds.h +++ /dev/null @@ -1,41 +0,0 @@ -/* The GIMP -- an image manipulation program - * Copyright (C) 1995 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. - */ -#ifndef __GIMAGE_MASK_CMDS_H__ -#define __GIMAGE_MASK_CMDS_H__ - -#include "procedural_db.h" - -extern ProcRecord gimage_mask_bounds_proc; -extern ProcRecord gimage_mask_value_proc; -extern ProcRecord gimage_mask_is_empty_proc; -extern ProcRecord gimage_mask_translate_proc; -extern ProcRecord gimage_mask_float_proc; -extern ProcRecord gimage_mask_clear_proc; -extern ProcRecord gimage_mask_invert_proc; -extern ProcRecord gimage_mask_sharpen_proc; -extern ProcRecord gimage_mask_all_proc; -extern ProcRecord gimage_mask_none_proc; -extern ProcRecord gimage_mask_feather_proc; -extern ProcRecord gimage_mask_border_proc; -extern ProcRecord gimage_mask_grow_proc; -extern ProcRecord gimage_mask_shrink_proc; -extern ProcRecord gimage_mask_layer_alpha_proc; -extern ProcRecord gimage_mask_load_proc; -extern ProcRecord gimage_mask_save_proc; - -#endif /* __GIMAGE_MASK_CMDS_H__ */ diff --git a/app/internal_procs.c b/app/internal_procs.c index 623b39b33c..19fe6a4548 100644 --- a/app/internal_procs.c +++ b/app/internal_procs.c @@ -21,7 +21,6 @@ #include "appenv.h" #include "app_procs.h" #include "gimage_cmds.h" -#include "gimage_mask_cmds.h" #include "internal_procs.h" #include "procedural_db.h" @@ -52,6 +51,7 @@ void register_parasite_procs (void); void register_drawable_procs (void); void register_procedural_db_procs (void); void register_layer_procs (void); +void register_gimage_mask_procs (void); void internal_procs_init (void) @@ -156,23 +156,8 @@ internal_procs_init (void) pcount/total_pcount); /* GImage mask procedures */ - procedural_db_register (&gimage_mask_bounds_proc); pcount++; - procedural_db_register (&gimage_mask_value_proc); pcount++; - procedural_db_register (&gimage_mask_is_empty_proc); pcount++; - procedural_db_register (&gimage_mask_translate_proc); pcount++; - procedural_db_register (&gimage_mask_float_proc); pcount++; - procedural_db_register (&gimage_mask_clear_proc); pcount++; - procedural_db_register (&gimage_mask_invert_proc); pcount++; - procedural_db_register (&gimage_mask_sharpen_proc); pcount++; - procedural_db_register (&gimage_mask_all_proc); pcount++; - procedural_db_register (&gimage_mask_none_proc); pcount++; - procedural_db_register (&gimage_mask_feather_proc); pcount++; - procedural_db_register (&gimage_mask_border_proc); pcount++; - procedural_db_register (&gimage_mask_grow_proc); pcount++; - procedural_db_register (&gimage_mask_shrink_proc); pcount++; - procedural_db_register (&gimage_mask_layer_alpha_proc); pcount++; - procedural_db_register (&gimage_mask_load_proc); pcount++; - procedural_db_register (&gimage_mask_save_proc); pcount++; + register_gimage_mask_procs (); + pcount += 19; app_init_update_status(NULL, _("Layer procedures"), pcount/total_pcount); diff --git a/tools/pdbgen/groups.pl b/tools/pdbgen/groups.pl index ea4bfaa729..f5ebe2a1c6 100644 --- a/tools/pdbgen/groups.pl +++ b/tools/pdbgen/groups.pl @@ -19,4 +19,4 @@ @groups = qw(gdisplay edit floating_sel undo palette gradient convert channel_ops gimprc drawable parasite paths gradient_select unit procedural_db brushes text_tool brush_select color - misc tools channel patterns pattern_select layer); + misc tools channel patterns pattern_select layer gimage_mask); diff --git a/tools/pdbgen/pdb/channel.pdb b/tools/pdbgen/pdb/channel.pdb index 1834d97afc..cdcff3c91f 100644 --- a/tools/pdbgen/pdb/channel.pdb +++ b/tools/pdbgen/pdb/channel.pdb @@ -28,7 +28,7 @@ sub channel_get_prop_proc { $blurb = "Get the $desc of the specified channel."; - $help = "This procedure returns the specified channel's $desc."; + $help = "This procedure returns the specified channel's $desc. "; &std_pdb_misc; @@ -62,7 +62,7 @@ sub channel_set_prop_proc { $blurb = "Set the $desc of the specified channel."; - $help = "This procedure sets the specified channel's $desc."; + $help = "This procedure sets the specified channel's $desc. "; &std_pdb_misc; @@ -205,8 +205,8 @@ HELP &channel_accessors('show_masked', 'boolean', 'composite method', 0, <<'CODE'); $help .= <<'HELP' - If it is non-zero, then the channel is composited with the image so that -masked regions are shown. Otherwise, selected regions are shown. +If it is non-zero, then the channel is composited with the image so that masked +regions are shown. Otherwise, selected regions are shown. HELP CODE diff --git a/tools/pdbgen/pdb/gimage_mask.pdb b/tools/pdbgen/pdb/gimage_mask.pdb new file mode 100644 index 0000000000..9e93f7c182 --- /dev/null +++ b/tools/pdbgen/pdb/gimage_mask.pdb @@ -0,0 +1,371 @@ +# The GIMP -- an image manipulation program +# Copyright (C) 1995 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. + +# "Perlized" from C source by Manish Singh + +sub coord_args { + my ($name, $desc, $args) = @_; + foreach (qw(x y)) { + push @$args, { name => eval qq/"$name"/, type => 'int32', + desc => eval qq/"$desc"/ } + } +} + +sub selection_simple_proc { + my $op = shift; + + &std_pdb_misc; + + @inargs = ( &std_image_arg ); + + %invoke = ( code => "gimage_mask_$op (gimage);" ); +} + +sub selection_change_proc { + my ($op, $arg, $type) = @_; + + $blurb = ucfirst($op) . " the image's selection"; + + $help = "This procedure ${op}s the selection. "; + + &std_pdb_misc; + + @inargs = ( + &std_image_arg, + { name => $arg, type => "0 < $type", + desc => ucfirst($arg) . " of $op (in pixels)" } + ); + + %invoke = ( code => "gimage_mask_$op (gimage, $arg);" ); +} + +# The defs + +sub selection_bounds { + $blurb = 'Find the bounding box of the current selection.'; + + $help = <<'HELP'; +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. +HELP + + &std_pdb_misc; + + @inargs = ( &std_image_arg ); + + @outargs = ( + { name => 'non_empty', type => 'boolean', + desc => 'True if there is a selection', init => 1 } + ); + + my $count = 1; + foreach ('upper left', 'lower right') { + &coord_args("\${_}$count", + "\$_ coordinate of $_ corner of selection bounds", + \@outargs); + $count++; + } + + %invoke = ( + code => 'non_empty = gimage_mask_bounds (gimage, &x1, &y1, &x2, &y2);' + ); +} + +sub selection_value { + $blurb = 'Find the value of the selection at the specified coordinates.'; + + $help = <<'HELP'; +This procedure returns the value of the selection at the specified coordinates. +If the coordinates lie out of bounds, 0 is returned. +HELP + + &std_pdb_misc; + + @inargs = ( &std_image_arg ); + &coord_args('$_', '$_ coordinate of value', \@inargs); + + @outargs = ( + { name => 'value', type => '0 <= int32 <= 255', + desc => 'Value of the selection: (%%desc%%)', + alias => 'gimage_mask_value (gimage, x, y)', no_declare => 1 } + ); +} + +sub selection_is_empty { + $blurb = 'Determine whether the selection in empty.'; + + $help = <<'HELP'; +This procedure returns non-zero if the selection for the specified image is not +empty. +HELP + + &std_pdb_misc; + + @inargs = ( &std_image_arg); + + @outargs = ( + { name => 'is_empty', type => 'boolean', + desc => 'Is the selection empty?', + alias => 'gimage_mask_is_empty (gimage)', no_declare => 1 } + ); +} + +sub selection_translate { + $blurb = 'Translate the selection by the specified offsets.'; + + $help = <<'HELP'; +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. +HELP + + &std_pdb_misc; + + @inargs = ( &std_image_arg ); + &coord_args('off$_', '$_ offset for translation', \@inargs); + + %invoke = ( code => 'gimage_mask_translate (gimage, offx, offy);' ); +} + +sub selection_float { + $blurb = <<'BLURB'; +Float the selection from the specified drawable with initial offsets as +specified. +BLURB + + $help = <<'HELP'; +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. +HELP + + &std_pdb_misc; + + @inargs = ( + { name => 'drawable', type => 'drawable', + desc => 'The drawable from which to float selection' } + ); + &coord_args('off$_', '$_ offset for translation', \@inargs); + + @outargs = ( + { name => 'layer', type => 'layer', + desc => 'The floated layer', init => 1 } + ); + + %invoke = ( + vars => [ 'GimpImage *gimage' ], + code => <<'CODE' +{ + gimage = drawable_gimage (drawable); + layer = gimage_mask_float (gimage, drawable, offx, offy); + success = layer != NULL; +} +CODE + ); +} + +sub selection_clear { + &selection_simple_proc('clear'); + + $blurb = 'Set the selection to none, clearing all previous content.'; + + $help = <<'HELP'; +This procedure sets the selection mask to empty, assigning the value 0 to every +pixel in the selection channel. +HELP +} + +sub selection_invert { + &selection_simple_proc('invert'); + + $blurb = 'Invert the selection mask.'; + + $help = <<'HELP'; +This procedure inverts the selection mask. For every pixel in the selection +channel, its new value is calculated as (255 - old_value). +HELP +} + +sub selection_sharpen { + &selection_simple_proc('sharpen'); + + $blurb = 'Sharpen the selection mask.'; + + $help = <<'HELP'; +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. +HELP +} + +sub selection_all { + &selection_simple_proc('all'); + + $blurb = 'Select all of the image.'; + + $help = <<'HELP'; +This procedure sets the selection mask to completely encompass the image. Every +pixel in the selection channel is set to 255. +HELP +} + +sub selection_none { + &selection_simple_proc('none'); + + $blurb = 'Deselect the entire image.'; + + $help = <<'HELP'; +This procedure deselects the entire image. Every pixel in the selection channel +is set to 0. +HELP +} + +sub selection_feather { + &selection_change_proc('feather', 'radius', 'float'); + + $help .= 'Feathering is implemented using a gaussian blur.'; +} + +sub selection_border { + &selection_change_proc('border', 'radius', 'int32'); + + $help .= <<'HELP'; +Bordering creates a new selection which is defined along the boundary of the +previous selection at every point within the specified radius. +HELP +} + +sub selection_grow { + &selection_change_proc('grow', 'steps', 'int32'); + + $help .= <<'HELP'; +Growing involves expanding the boundary in all directions by the specified +pixel amount. +HELP +} + +sub selection_shrink { + &selection_change_proc('shrink', 'radius', 'int32'); + + $help .= <<'HELP'; +Shrinking invovles trimming the existing selection boundary on all sides by the +specified number of pixels. +HELP +} + +sub selection_layer_alpha { + $blurb = <<'BLURB'; +Transfer the specified layer's alpha channel to the selection mask. +BLURB + + $help = <<'HELP'; +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. +HELP + + &std_pdb_misc; + + @inargs = ( + { name => 'layer', type => 'layer', + desc => 'Layer with alpha' } + ); + + %invoke = ( + vars => [ 'GimpImage *gimage' ], + code => <<'CODE' +{ + gimage = drawable_gimage (GIMP_DRAWABLE (layer)); + gimage_mask_layer_alpha (gimage, layer); +} +CODE + ); +} + +sub selection_load { + $blurb = 'Transfer the specified channel to the selection mask.'; + + $help = <<'HELP'; +This procedure loads the specified channel into the selection mask. This +essentially involves a copy of the channel's content in to the selection mask. +Therefore, the channel must have the same width and height of the image, or an +error is returned. +HELP + + &std_pdb_misc; + + @inargs = ( + { name => 'channel', type => 'channel', + desc => 'The channel' } + ); + + %invoke = ( + vars => [ 'GimpImage *gimage' ], + code => <<'CODE' +{ + gimage = drawable_gimage (GIMP_DRAWABLE (channel)); + + if (drawable_width (GIMP_DRAWABLE (channel)) == gimage->width && + drawable_height (GIMP_DRAWABLE (channel)) == gimage->height) + gimage_mask_load (gimage, channel); + else + success = FALSE; +} +CODE + ); +} + +sub selection_save { + $blurb = 'Copy the selection mask to a new channel.'; + + $help = <<'HELP'; +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. +HELP + + &std_pdb_misc; + + @inargs = ( &std_image_arg ); + + @outargs = ( + { name => 'channel', type => 'channel', + desc => 'The new channel', init => 1 } + ); + + %invoke = ( + code => 'success = (channel = gimage_mask_save (gimage)) != NULL;' + ); +} + +@headers = qw("gimage_mask.h"); + +@procs = qw(selection_bounds selection_value selection_is_empty + selection_translate selection_float selection_clear + selection_invert selection_sharpen selection_all selection_none + selection_feather selection_border selection_grow selection_shrink + selection_layer_alpha selection_load selection_save); +%exports = (app => [@procs]); + +$desc = 'Image mask'; + +1; diff --git a/tools/pdbgen/pdb/layer.pdb b/tools/pdbgen/pdb/layer.pdb index ea0f8fe1a3..03c941f89d 100644 --- a/tools/pdbgen/pdb/layer.pdb +++ b/tools/pdbgen/pdb/layer.pdb @@ -106,7 +106,7 @@ sub layer_get_prop_proc { $blurb = "Get the $desc of the specified layer."; - $help = "This procedure returns the specified layer's $desc."; + $help = "This procedure returns the specified layer's $desc. "; &std_pdb_misc; @@ -140,7 +140,7 @@ sub layer_set_prop_proc { $blurb = "Set the $desc of the specified layer."; - $help = "This procedure sets the specified layer's $desc."; + $help = "This procedure sets the specified layer's $desc. "; &std_pdb_misc; @@ -474,12 +474,12 @@ HELP &layer_accessors('apply_mask', 'boolean', 'apply mask', 0, 1, [ <<'CODE1', <<'CODE2' ]); $help .= <<'HELP'; - If the value is non-zero, then the layer mask for this layer is currently -being composited with the layer's alpha channel. +If the value is non-zero, then the layer mask for this layer is currently being +composited with the layer's alpha channel. HELP CODE1 $help .= <<'HELP'; - This controls whether the layer's mask is currently affecting the alpha +This controls whether the layer's mask is currently affecting the alpha channel. If there is no layer mask, this function will return an error. HELP CODE2 @@ -487,12 +487,12 @@ CODE2 &layer_accessors('show_mask', 'boolean', 'show mask', 0, 1, [ <<'CODE1', <<'CODE2' ]); $help .= <<'HELP'; - If the value is non-zero, then the layer mask for this layer is currently -being shown instead of the layer. +If the value is non-zero, then the layer mask for this layer is currently being +shown instead of the layer. HELP CODE1 $help .= <<'HELP'; - This controls whether the layer or it's mask is visible. Non-zero values +This controls whether the layer or it's mask is visible. Non-zero values indicate that the mask should be visible. If the layer has no mask, then this function returns an error. HELP @@ -506,7 +506,7 @@ active, and not the layer. HELP CODE1 $help .= <<'HELP'; - This controls whether the layer or it's mask is currently active for editing. +This controls whether the layer or it's mask is currently active for editing. If the specified layer has no layer mask, then this procedure will return an error. HELP diff --git a/tools/pdbgen/pdb/selection.pdb b/tools/pdbgen/pdb/selection.pdb new file mode 100644 index 0000000000..9e93f7c182 --- /dev/null +++ b/tools/pdbgen/pdb/selection.pdb @@ -0,0 +1,371 @@ +# The GIMP -- an image manipulation program +# Copyright (C) 1995 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. + +# "Perlized" from C source by Manish Singh + +sub coord_args { + my ($name, $desc, $args) = @_; + foreach (qw(x y)) { + push @$args, { name => eval qq/"$name"/, type => 'int32', + desc => eval qq/"$desc"/ } + } +} + +sub selection_simple_proc { + my $op = shift; + + &std_pdb_misc; + + @inargs = ( &std_image_arg ); + + %invoke = ( code => "gimage_mask_$op (gimage);" ); +} + +sub selection_change_proc { + my ($op, $arg, $type) = @_; + + $blurb = ucfirst($op) . " the image's selection"; + + $help = "This procedure ${op}s the selection. "; + + &std_pdb_misc; + + @inargs = ( + &std_image_arg, + { name => $arg, type => "0 < $type", + desc => ucfirst($arg) . " of $op (in pixels)" } + ); + + %invoke = ( code => "gimage_mask_$op (gimage, $arg);" ); +} + +# The defs + +sub selection_bounds { + $blurb = 'Find the bounding box of the current selection.'; + + $help = <<'HELP'; +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. +HELP + + &std_pdb_misc; + + @inargs = ( &std_image_arg ); + + @outargs = ( + { name => 'non_empty', type => 'boolean', + desc => 'True if there is a selection', init => 1 } + ); + + my $count = 1; + foreach ('upper left', 'lower right') { + &coord_args("\${_}$count", + "\$_ coordinate of $_ corner of selection bounds", + \@outargs); + $count++; + } + + %invoke = ( + code => 'non_empty = gimage_mask_bounds (gimage, &x1, &y1, &x2, &y2);' + ); +} + +sub selection_value { + $blurb = 'Find the value of the selection at the specified coordinates.'; + + $help = <<'HELP'; +This procedure returns the value of the selection at the specified coordinates. +If the coordinates lie out of bounds, 0 is returned. +HELP + + &std_pdb_misc; + + @inargs = ( &std_image_arg ); + &coord_args('$_', '$_ coordinate of value', \@inargs); + + @outargs = ( + { name => 'value', type => '0 <= int32 <= 255', + desc => 'Value of the selection: (%%desc%%)', + alias => 'gimage_mask_value (gimage, x, y)', no_declare => 1 } + ); +} + +sub selection_is_empty { + $blurb = 'Determine whether the selection in empty.'; + + $help = <<'HELP'; +This procedure returns non-zero if the selection for the specified image is not +empty. +HELP + + &std_pdb_misc; + + @inargs = ( &std_image_arg); + + @outargs = ( + { name => 'is_empty', type => 'boolean', + desc => 'Is the selection empty?', + alias => 'gimage_mask_is_empty (gimage)', no_declare => 1 } + ); +} + +sub selection_translate { + $blurb = 'Translate the selection by the specified offsets.'; + + $help = <<'HELP'; +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. +HELP + + &std_pdb_misc; + + @inargs = ( &std_image_arg ); + &coord_args('off$_', '$_ offset for translation', \@inargs); + + %invoke = ( code => 'gimage_mask_translate (gimage, offx, offy);' ); +} + +sub selection_float { + $blurb = <<'BLURB'; +Float the selection from the specified drawable with initial offsets as +specified. +BLURB + + $help = <<'HELP'; +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. +HELP + + &std_pdb_misc; + + @inargs = ( + { name => 'drawable', type => 'drawable', + desc => 'The drawable from which to float selection' } + ); + &coord_args('off$_', '$_ offset for translation', \@inargs); + + @outargs = ( + { name => 'layer', type => 'layer', + desc => 'The floated layer', init => 1 } + ); + + %invoke = ( + vars => [ 'GimpImage *gimage' ], + code => <<'CODE' +{ + gimage = drawable_gimage (drawable); + layer = gimage_mask_float (gimage, drawable, offx, offy); + success = layer != NULL; +} +CODE + ); +} + +sub selection_clear { + &selection_simple_proc('clear'); + + $blurb = 'Set the selection to none, clearing all previous content.'; + + $help = <<'HELP'; +This procedure sets the selection mask to empty, assigning the value 0 to every +pixel in the selection channel. +HELP +} + +sub selection_invert { + &selection_simple_proc('invert'); + + $blurb = 'Invert the selection mask.'; + + $help = <<'HELP'; +This procedure inverts the selection mask. For every pixel in the selection +channel, its new value is calculated as (255 - old_value). +HELP +} + +sub selection_sharpen { + &selection_simple_proc('sharpen'); + + $blurb = 'Sharpen the selection mask.'; + + $help = <<'HELP'; +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. +HELP +} + +sub selection_all { + &selection_simple_proc('all'); + + $blurb = 'Select all of the image.'; + + $help = <<'HELP'; +This procedure sets the selection mask to completely encompass the image. Every +pixel in the selection channel is set to 255. +HELP +} + +sub selection_none { + &selection_simple_proc('none'); + + $blurb = 'Deselect the entire image.'; + + $help = <<'HELP'; +This procedure deselects the entire image. Every pixel in the selection channel +is set to 0. +HELP +} + +sub selection_feather { + &selection_change_proc('feather', 'radius', 'float'); + + $help .= 'Feathering is implemented using a gaussian blur.'; +} + +sub selection_border { + &selection_change_proc('border', 'radius', 'int32'); + + $help .= <<'HELP'; +Bordering creates a new selection which is defined along the boundary of the +previous selection at every point within the specified radius. +HELP +} + +sub selection_grow { + &selection_change_proc('grow', 'steps', 'int32'); + + $help .= <<'HELP'; +Growing involves expanding the boundary in all directions by the specified +pixel amount. +HELP +} + +sub selection_shrink { + &selection_change_proc('shrink', 'radius', 'int32'); + + $help .= <<'HELP'; +Shrinking invovles trimming the existing selection boundary on all sides by the +specified number of pixels. +HELP +} + +sub selection_layer_alpha { + $blurb = <<'BLURB'; +Transfer the specified layer's alpha channel to the selection mask. +BLURB + + $help = <<'HELP'; +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. +HELP + + &std_pdb_misc; + + @inargs = ( + { name => 'layer', type => 'layer', + desc => 'Layer with alpha' } + ); + + %invoke = ( + vars => [ 'GimpImage *gimage' ], + code => <<'CODE' +{ + gimage = drawable_gimage (GIMP_DRAWABLE (layer)); + gimage_mask_layer_alpha (gimage, layer); +} +CODE + ); +} + +sub selection_load { + $blurb = 'Transfer the specified channel to the selection mask.'; + + $help = <<'HELP'; +This procedure loads the specified channel into the selection mask. This +essentially involves a copy of the channel's content in to the selection mask. +Therefore, the channel must have the same width and height of the image, or an +error is returned. +HELP + + &std_pdb_misc; + + @inargs = ( + { name => 'channel', type => 'channel', + desc => 'The channel' } + ); + + %invoke = ( + vars => [ 'GimpImage *gimage' ], + code => <<'CODE' +{ + gimage = drawable_gimage (GIMP_DRAWABLE (channel)); + + if (drawable_width (GIMP_DRAWABLE (channel)) == gimage->width && + drawable_height (GIMP_DRAWABLE (channel)) == gimage->height) + gimage_mask_load (gimage, channel); + else + success = FALSE; +} +CODE + ); +} + +sub selection_save { + $blurb = 'Copy the selection mask to a new channel.'; + + $help = <<'HELP'; +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. +HELP + + &std_pdb_misc; + + @inargs = ( &std_image_arg ); + + @outargs = ( + { name => 'channel', type => 'channel', + desc => 'The new channel', init => 1 } + ); + + %invoke = ( + code => 'success = (channel = gimage_mask_save (gimage)) != NULL;' + ); +} + +@headers = qw("gimage_mask.h"); + +@procs = qw(selection_bounds selection_value selection_is_empty + selection_translate selection_float selection_clear + selection_invert selection_sharpen selection_all selection_none + selection_feather selection_border selection_grow selection_shrink + selection_layer_alpha selection_load selection_save); +%exports = (app => [@procs]); + +$desc = 'Image mask'; + +1;