diff --git a/ChangeLog b/ChangeLog index 255ff55832..b4d37233f3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,28 @@ +2003-12-08 Michael Natterer + + Some PDB fixes/cosmetics before doing real changes again: + + * tools/pdbgen/pdb/drawable.pdb + * tools/pdbgen/pdb/layer.pdb: changed order of generated functions + to make more sense. + + * tools/pdbgen/pdb/misc_tools.pdb: doc cosmetics, removed unused + subroutines. + + * tools/pdbgen/pdb/image.pdb: reordered generated functions as + above, fixed resolution and unit accessors to use functions + instead of setting gimage->foo directly, use &image_accessors() + for the tattoo_state functions, cleanup. + + * app/pdb/drawable_cmds.c + * app/pdb/image_cmds.c + * app/pdb/layer_cmds.c + * app/pdb/misc_tools_cmds.c + * libgimp/gimpdrawable_pdb.[ch] + * libgimp/gimpimage_pdb.[ch] + * libgimp/gimplayer_pdb.[ch] + * libgimp/gimpmisctools_pdb.c: regenerated. + 2003-12-08 Sven Neumann * libgimpthumb/gimpthumbnail.c (gimp_thumbnail_load_thumb): don't diff --git a/app/pdb/drawable_cmds.c b/app/pdb/drawable_cmds.c index edfa85cf0d..d4aec37731 100644 --- a/app/pdb/drawable_cmds.c +++ b/app/pdb/drawable_cmds.c @@ -41,15 +41,13 @@ #include "gimp-intl.h" #include "plug-in/plug-in.h" -static ProcRecord drawable_merge_shadow_proc; -static ProcRecord drawable_fill_proc; -static ProcRecord drawable_update_proc; -static ProcRecord drawable_mask_bounds_proc; -static ProcRecord drawable_get_image_proc; -static ProcRecord drawable_set_image_proc; -static ProcRecord drawable_has_alpha_proc; +static ProcRecord drawable_delete_proc; +static ProcRecord drawable_is_layer_proc; +static ProcRecord drawable_is_layer_mask_proc; +static ProcRecord drawable_is_channel_proc; static ProcRecord drawable_type_proc; static ProcRecord drawable_type_with_alpha_proc; +static ProcRecord drawable_has_alpha_proc; static ProcRecord drawable_is_rgb_proc; static ProcRecord drawable_is_gray_proc; static ProcRecord drawable_is_indexed_proc; @@ -57,9 +55,8 @@ static ProcRecord drawable_bpp_proc; static ProcRecord drawable_width_proc; static ProcRecord drawable_height_proc; static ProcRecord drawable_offsets_proc; -static ProcRecord drawable_is_layer_proc; -static ProcRecord drawable_is_layer_mask_proc; -static ProcRecord drawable_is_channel_proc; +static ProcRecord drawable_get_image_proc; +static ProcRecord drawable_set_image_proc; static ProcRecord drawable_get_name_proc; static ProcRecord drawable_set_name_proc; static ProcRecord drawable_get_visible_proc; @@ -68,24 +65,25 @@ static ProcRecord drawable_get_linked_proc; static ProcRecord drawable_set_linked_proc; static ProcRecord drawable_get_tattoo_proc; static ProcRecord drawable_set_tattoo_proc; +static ProcRecord drawable_mask_bounds_proc; +static ProcRecord drawable_merge_shadow_proc; +static ProcRecord drawable_update_proc; static ProcRecord drawable_get_pixel_proc; static ProcRecord drawable_set_pixel_proc; -static ProcRecord drawable_thumbnail_proc; +static ProcRecord drawable_fill_proc; static ProcRecord drawable_offset_proc; -static ProcRecord drawable_delete_proc; +static ProcRecord drawable_thumbnail_proc; void register_drawable_procs (Gimp *gimp) { - procedural_db_register (gimp, &drawable_merge_shadow_proc); - procedural_db_register (gimp, &drawable_fill_proc); - procedural_db_register (gimp, &drawable_update_proc); - procedural_db_register (gimp, &drawable_mask_bounds_proc); - procedural_db_register (gimp, &drawable_get_image_proc); - procedural_db_register (gimp, &drawable_set_image_proc); - procedural_db_register (gimp, &drawable_has_alpha_proc); + procedural_db_register (gimp, &drawable_delete_proc); + procedural_db_register (gimp, &drawable_is_layer_proc); + procedural_db_register (gimp, &drawable_is_layer_mask_proc); + procedural_db_register (gimp, &drawable_is_channel_proc); procedural_db_register (gimp, &drawable_type_proc); procedural_db_register (gimp, &drawable_type_with_alpha_proc); + procedural_db_register (gimp, &drawable_has_alpha_proc); procedural_db_register (gimp, &drawable_is_rgb_proc); procedural_db_register (gimp, &drawable_is_gray_proc); procedural_db_register (gimp, &drawable_is_indexed_proc); @@ -93,9 +91,8 @@ register_drawable_procs (Gimp *gimp) procedural_db_register (gimp, &drawable_width_proc); procedural_db_register (gimp, &drawable_height_proc); procedural_db_register (gimp, &drawable_offsets_proc); - procedural_db_register (gimp, &drawable_is_layer_proc); - procedural_db_register (gimp, &drawable_is_layer_mask_proc); - procedural_db_register (gimp, &drawable_is_channel_proc); + procedural_db_register (gimp, &drawable_get_image_proc); + procedural_db_register (gimp, &drawable_set_image_proc); procedural_db_register (gimp, &drawable_get_name_proc); procedural_db_register (gimp, &drawable_set_name_proc); procedural_db_register (gimp, &drawable_get_visible_proc); @@ -104,401 +101,66 @@ register_drawable_procs (Gimp *gimp) procedural_db_register (gimp, &drawable_set_linked_proc); procedural_db_register (gimp, &drawable_get_tattoo_proc); procedural_db_register (gimp, &drawable_set_tattoo_proc); + procedural_db_register (gimp, &drawable_mask_bounds_proc); + procedural_db_register (gimp, &drawable_merge_shadow_proc); + procedural_db_register (gimp, &drawable_update_proc); procedural_db_register (gimp, &drawable_get_pixel_proc); procedural_db_register (gimp, &drawable_set_pixel_proc); - procedural_db_register (gimp, &drawable_thumbnail_proc); + procedural_db_register (gimp, &drawable_fill_proc); procedural_db_register (gimp, &drawable_offset_proc); - procedural_db_register (gimp, &drawable_delete_proc); + procedural_db_register (gimp, &drawable_thumbnail_proc); } static Argument * -drawable_merge_shadow_invoker (Gimp *gimp, - Argument *args) -{ - gboolean success = TRUE; - GimpDrawable *drawable; - gboolean undo; - gchar *undo_desc = NULL; - - drawable = (GimpDrawable *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int); - if (! GIMP_IS_DRAWABLE (drawable)) - success = FALSE; - - undo = args[1].value.pdb_int ? TRUE : FALSE; - - if (success) - { - if (gimp->current_plug_in) - undo_desc = plug_in_get_undo_desc (gimp->current_plug_in); - - if (! undo_desc) - undo_desc = g_strdup (_("Plug-In")); - - gimp_drawable_merge_shadow (drawable, undo, undo_desc); - - g_free (undo_desc); - } - - return procedural_db_return_args (&drawable_merge_shadow_proc, success); -} - -static ProcArg drawable_merge_shadow_inargs[] = -{ - { - GIMP_PDB_DRAWABLE, - "drawable", - "The drawable" - }, - { - GIMP_PDB_INT32, - "undo", - "Push merge to undo stack?" - } -}; - -static ProcRecord drawable_merge_shadow_proc = -{ - "gimp_drawable_merge_shadow", - "Merge the shadow buffer with the specified drawable.", - "This procedure combines the contents of the image's shadow buffer (for temporary processing) with the specified drawable. The \"undo\" parameter specifies whether to add an undo step for the operation. Requesting no undo is useful for such applications as 'auto-apply'.", - "Spencer Kimball & Peter Mattis", - "Spencer Kimball & Peter Mattis", - "1995-1996", - GIMP_INTERNAL, - 2, - drawable_merge_shadow_inargs, - 0, - NULL, - { { drawable_merge_shadow_invoker } } -}; - -static Argument * -drawable_fill_invoker (Gimp *gimp, - Argument *args) -{ - gboolean success = TRUE; - GimpDrawable *drawable; - gint32 fill_type; - - drawable = (GimpDrawable *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int); - if (! GIMP_IS_DRAWABLE (drawable)) - success = FALSE; - - fill_type = args[1].value.pdb_int; - if (fill_type < GIMP_FOREGROUND_FILL || fill_type > GIMP_NO_FILL) - success = FALSE; - - if (success) - gimp_drawable_fill_by_type (drawable, gimp_get_current_context (gimp), (GimpFillType) fill_type); - - return procedural_db_return_args (&drawable_fill_proc, success); -} - -static ProcArg drawable_fill_inargs[] = -{ - { - GIMP_PDB_DRAWABLE, - "drawable", - "The drawable" - }, - { - GIMP_PDB_INT32, - "fill_type", - "The type of fill: GIMP_FOREGROUND_FILL (0), GIMP_BACKGROUND_FILL (1), GIMP_WHITE_FILL (2), GIMP_TRANSPARENT_FILL (3), GIMP_NO_FILL (4)" - } -}; - -static ProcRecord drawable_fill_proc = -{ - "gimp_drawable_fill", - "Fill the drawable with the specified fill mode.", - "This procedure fills the drawable with the fill mode. If the fill mode is foreground the current foreground color is used. If the fill mode is background, the current background color is used. If the fill type is white, then white is used. Transparent fill only affects layers with an alpha channel, in which case the alpha channel is set to transparent. If the drawable has no alpha channel, it is filled to white. No fill leaves the drawable's contents undefined. This procedure is unlike the bucket fill tool because it fills regardless of a selection", - "Spencer Kimball & Peter Mattis", - "Spencer Kimball & Peter Mattis", - "1995-1996", - GIMP_INTERNAL, - 2, - drawable_fill_inargs, - 0, - NULL, - { { drawable_fill_invoker } } -}; - -static Argument * -drawable_update_invoker (Gimp *gimp, +drawable_delete_invoker (Gimp *gimp, Argument *args) { gboolean success = TRUE; GimpDrawable *drawable; - gint32 x; - gint32 y; - gint32 width; - gint32 height; drawable = (GimpDrawable *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int); if (! GIMP_IS_DRAWABLE (drawable)) success = FALSE; - x = args[1].value.pdb_int; - - y = args[2].value.pdb_int; - - width = args[3].value.pdb_int; - - height = args[4].value.pdb_int; - - if (success) - gimp_drawable_update (drawable, x, y, width, height); - - return procedural_db_return_args (&drawable_update_proc, success); -} - -static ProcArg drawable_update_inargs[] = -{ - { - GIMP_PDB_DRAWABLE, - "drawable", - "The drawable" - }, - { - GIMP_PDB_INT32, - "x", - "x coordinate of upper left corner of update region" - }, - { - GIMP_PDB_INT32, - "y", - "y coordinate of upper left corner of update region" - }, - { - GIMP_PDB_INT32, - "width", - "Width of update region" - }, - { - GIMP_PDB_INT32, - "height", - "Height of update region" - } -}; - -static ProcRecord drawable_update_proc = -{ - "gimp_drawable_update", - "Update the specified region of the drawable.", - "This procedure updates the specified region of the drawable. The (x, y) coordinate pair is relative to the drawable's origin, not to the image origin. Therefore, the entire drawable can be updated with: {x->0, y->0, w->width, h->height }.", - "Spencer Kimball & Peter Mattis", - "Spencer Kimball & Peter Mattis", - "1995-1996", - GIMP_INTERNAL, - 5, - drawable_update_inargs, - 0, - NULL, - { { drawable_update_invoker } } -}; - -static Argument * -drawable_mask_bounds_invoker (Gimp *gimp, - Argument *args) -{ - gboolean success = TRUE; - Argument *return_args; - GimpDrawable *drawable; - gboolean non_empty = FALSE; - gint32 x1; - gint32 y1; - gint32 x2; - gint32 y2; - - drawable = (GimpDrawable *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int); - if (! GIMP_IS_DRAWABLE (drawable)) - success = FALSE; - - if (success) - non_empty = gimp_drawable_mask_bounds (drawable, &x1, &y1, &x2, &y2); - - return_args = procedural_db_return_args (&drawable_mask_bounds_proc, success); - if (success) { - return_args[1].value.pdb_int = non_empty; - return_args[2].value.pdb_int = x1; - return_args[3].value.pdb_int = y1; - return_args[4].value.pdb_int = x2; - return_args[5].value.pdb_int = y2; + if (! gimp_item_get_image (GIMP_ITEM (drawable))) + g_object_unref (drawable); + else + success = FALSE; } - return return_args; + return procedural_db_return_args (&drawable_delete_proc, success); } -static ProcArg drawable_mask_bounds_inargs[] = +static ProcArg drawable_delete_inargs[] = { { GIMP_PDB_DRAWABLE, "drawable", - "The drawable" + "The drawable to delete" } }; -static ProcArg drawable_mask_bounds_outargs[] = +static ProcRecord drawable_delete_proc = { - { - GIMP_PDB_INT32, - "non_empty", - "TRUE if there is a selection" - }, - { - GIMP_PDB_INT32, - "x1", - "x coordinate of the upper left corner of selection bounds" - }, - { - GIMP_PDB_INT32, - "y1", - "y coordinate of the upper left corner of selection bounds" - }, - { - GIMP_PDB_INT32, - "x2", - "x coordinate of the lower right corner of selection bounds" - }, - { - GIMP_PDB_INT32, - "y2", - "y coordinate of the lower right corner of selection bounds" - } -}; - -static ProcRecord drawable_mask_bounds_proc = -{ - "gimp_drawable_mask_bounds", - "Find the bounding box of the current selection in relation to the specified drawable.", - "This procedure returns the whether there is a selection. If there is one, the upper left and lower righthand corners of its bounding box are returned. These coordinates are specified relative to the drawable's origin, and bounded by the drawable's extents. Please note that the pixel specified by the lower righthand coordinate of the bounding box is not part of the selection. The selection ends at the upper left corner of this pixel. This means the width of the selection can be calculated as (x2 - x1), its height as (y2 - y1).", + "gimp_drawable_delete", + "Delete a drawable.", + "This procedure deletes the specified drawable. This must not be done if the gimage containing this drawable was already deleted or if the drawable was already removed from the image. The only case in which this procedure is useful is if you want to get rid of a drawable which has not yet been added to an image.", "Spencer Kimball & Peter Mattis", "Spencer Kimball & Peter Mattis", "1995-1996", GIMP_INTERNAL, 1, - drawable_mask_bounds_inargs, - 5, - drawable_mask_bounds_outargs, - { { drawable_mask_bounds_invoker } } -}; - -static Argument * -drawable_get_image_invoker (Gimp *gimp, - Argument *args) -{ - gboolean success = TRUE; - Argument *return_args; - GimpDrawable *drawable; - GimpImage *gimage = NULL; - - drawable = (GimpDrawable *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int); - if (! GIMP_IS_DRAWABLE (drawable)) - success = FALSE; - - if (success) - success = (gimage = gimp_item_get_image (GIMP_ITEM (drawable))) != NULL; - - return_args = procedural_db_return_args (&drawable_get_image_proc, success); - - if (success) - return_args[1].value.pdb_int = gimp_image_get_ID (gimage); - - return return_args; -} - -static ProcArg drawable_get_image_inargs[] = -{ - { - GIMP_PDB_DRAWABLE, - "drawable", - "The drawable" - } -}; - -static ProcArg drawable_get_image_outargs[] = -{ - { - GIMP_PDB_IMAGE, - "image", - "The drawable's image" - } -}; - -static ProcRecord drawable_get_image_proc = -{ - "gimp_drawable_get_image", - "Returns the drawable's image.", - "This procedure returns the drawable's image.", - "Spencer Kimball & Peter Mattis", - "Spencer Kimball & Peter Mattis", - "1995-1996", - GIMP_INTERNAL, - 1, - drawable_get_image_inargs, - 1, - drawable_get_image_outargs, - { { drawable_get_image_invoker } } -}; - -static Argument * -drawable_set_image_invoker (Gimp *gimp, - Argument *args) -{ - gboolean success = TRUE; - GimpDrawable *drawable; - GimpImage *gimage; - - drawable = (GimpDrawable *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int); - if (! GIMP_IS_DRAWABLE (drawable)) - success = FALSE; - - gimage = gimp_image_get_by_ID (gimp, args[1].value.pdb_int); - if (! GIMP_IS_IMAGE (gimage)) - success = FALSE; - - if (success) - gimp_item_set_image (GIMP_ITEM (drawable), gimage); - - return procedural_db_return_args (&drawable_set_image_proc, success); -} - -static ProcArg drawable_set_image_inargs[] = -{ - { - GIMP_PDB_DRAWABLE, - "drawable", - "The drawable" - }, - { - GIMP_PDB_IMAGE, - "image", - "The image" - } -}; - -static ProcRecord drawable_set_image_proc = -{ - "gimp_drawable_set_image", - "Set image where drawable belongs to.", - "Set the image the drawable should be a part of (Use this before adding a drawable to another image).", - "Spencer Kimball & Peter Mattis", - "Spencer Kimball & Peter Mattis", - "1995-1996", - GIMP_INTERNAL, - 2, - drawable_set_image_inargs, + drawable_delete_inargs, 0, NULL, - { { drawable_set_image_invoker } } + { { drawable_delete_invoker } } }; static Argument * -drawable_has_alpha_invoker (Gimp *gimp, - Argument *args) +drawable_is_layer_invoker (Gimp *gimp, + Argument *args) { gboolean success = TRUE; Argument *return_args; @@ -508,15 +170,15 @@ drawable_has_alpha_invoker (Gimp *gimp, if (! GIMP_IS_DRAWABLE (drawable)) success = FALSE; - return_args = procedural_db_return_args (&drawable_has_alpha_proc, success); + return_args = procedural_db_return_args (&drawable_is_layer_proc, success); if (success) - return_args[1].value.pdb_int = gimp_drawable_has_alpha (drawable); + return_args[1].value.pdb_int = GIMP_IS_LAYER (drawable) ? TRUE : FALSE; return return_args; } -static ProcArg drawable_has_alpha_inargs[] = +static ProcArg drawable_is_layer_inargs[] = { { GIMP_PDB_DRAWABLE, @@ -525,29 +187,137 @@ static ProcArg drawable_has_alpha_inargs[] = } }; -static ProcArg drawable_has_alpha_outargs[] = +static ProcArg drawable_is_layer_outargs[] = { { GIMP_PDB_INT32, - "has_alpha", - "Does the drawable have an alpha channel?" + "layer", + "Non-zero if the drawable is a layer" } }; -static ProcRecord drawable_has_alpha_proc = +static ProcRecord drawable_is_layer_proc = { - "gimp_drawable_has_alpha", - "Returns non-zero if the drawable has an alpha channel.", - "This procedure returns whether the specified drawable has an alpha channel. This can only be true for layers, and the associated type will be one of: { RGBA , GRAYA, INDEXEDA }.", + "gimp_drawable_is_layer", + "Returns whether the drawable is a layer.", + "This procedure returns non-zero if the specified drawable is a layer.", "Spencer Kimball & Peter Mattis", "Spencer Kimball & Peter Mattis", "1995-1996", GIMP_INTERNAL, 1, - drawable_has_alpha_inargs, + drawable_is_layer_inargs, 1, - drawable_has_alpha_outargs, - { { drawable_has_alpha_invoker } } + drawable_is_layer_outargs, + { { drawable_is_layer_invoker } } +}; + +static Argument * +drawable_is_layer_mask_invoker (Gimp *gimp, + Argument *args) +{ + gboolean success = TRUE; + Argument *return_args; + GimpDrawable *drawable; + + drawable = (GimpDrawable *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int); + if (! GIMP_IS_DRAWABLE (drawable)) + success = FALSE; + + return_args = procedural_db_return_args (&drawable_is_layer_mask_proc, success); + + if (success) + return_args[1].value.pdb_int = GIMP_IS_LAYER_MASK (drawable) ? TRUE : FALSE; + + return return_args; +} + +static ProcArg drawable_is_layer_mask_inargs[] = +{ + { + GIMP_PDB_DRAWABLE, + "drawable", + "The drawable" + } +}; + +static ProcArg drawable_is_layer_mask_outargs[] = +{ + { + GIMP_PDB_INT32, + "layer_mask", + "Non-zero if the drawable is a layer mask" + } +}; + +static ProcRecord drawable_is_layer_mask_proc = +{ + "gimp_drawable_is_layer_mask", + "Returns whether the drawable is a layer mask.", + "This procedure returns non-zero if the specified drawable is a layer mask.", + "Spencer Kimball & Peter Mattis", + "Spencer Kimball & Peter Mattis", + "1995-1996", + GIMP_INTERNAL, + 1, + drawable_is_layer_mask_inargs, + 1, + drawable_is_layer_mask_outargs, + { { drawable_is_layer_mask_invoker } } +}; + +static Argument * +drawable_is_channel_invoker (Gimp *gimp, + Argument *args) +{ + gboolean success = TRUE; + Argument *return_args; + GimpDrawable *drawable; + + drawable = (GimpDrawable *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int); + if (! GIMP_IS_DRAWABLE (drawable)) + success = FALSE; + + return_args = procedural_db_return_args (&drawable_is_channel_proc, success); + + if (success) + return_args[1].value.pdb_int = GIMP_IS_CHANNEL (drawable) ? TRUE : FALSE; + + return return_args; +} + +static ProcArg drawable_is_channel_inargs[] = +{ + { + GIMP_PDB_DRAWABLE, + "drawable", + "The drawable" + } +}; + +static ProcArg drawable_is_channel_outargs[] = +{ + { + GIMP_PDB_INT32, + "channel", + "Non-zero if the drawable is a channel" + } +}; + +static ProcRecord drawable_is_channel_proc = +{ + "gimp_drawable_is_channel", + "Returns whether the drawable is a channel.", + "This procedure returns non-zero if the specified drawable is a channel.", + "Spencer Kimball & Peter Mattis", + "Spencer Kimball & Peter Mattis", + "1995-1996", + GIMP_INTERNAL, + 1, + drawable_is_channel_inargs, + 1, + drawable_is_channel_outargs, + { { drawable_is_channel_invoker } } }; static Argument * @@ -658,6 +428,60 @@ static ProcRecord drawable_type_with_alpha_proc = { { drawable_type_with_alpha_invoker } } }; +static Argument * +drawable_has_alpha_invoker (Gimp *gimp, + Argument *args) +{ + gboolean success = TRUE; + Argument *return_args; + GimpDrawable *drawable; + + drawable = (GimpDrawable *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int); + if (! GIMP_IS_DRAWABLE (drawable)) + success = FALSE; + + return_args = procedural_db_return_args (&drawable_has_alpha_proc, success); + + if (success) + return_args[1].value.pdb_int = gimp_drawable_has_alpha (drawable); + + return return_args; +} + +static ProcArg drawable_has_alpha_inargs[] = +{ + { + GIMP_PDB_DRAWABLE, + "drawable", + "The drawable" + } +}; + +static ProcArg drawable_has_alpha_outargs[] = +{ + { + GIMP_PDB_INT32, + "has_alpha", + "Does the drawable have an alpha channel?" + } +}; + +static ProcRecord drawable_has_alpha_proc = +{ + "gimp_drawable_has_alpha", + "Returns non-zero if the drawable has an alpha channel.", + "This procedure returns whether the specified drawable has an alpha channel. This can only be true for layers, and the associated type will be one of: { RGBA , GRAYA, INDEXEDA }.", + "Spencer Kimball & Peter Mattis", + "Spencer Kimball & Peter Mattis", + "1995-1996", + GIMP_INTERNAL, + 1, + drawable_has_alpha_inargs, + 1, + drawable_has_alpha_outargs, + { { drawable_has_alpha_invoker } } +}; + static Argument * drawable_is_rgb_invoker (Gimp *gimp, Argument *args) @@ -1050,26 +874,30 @@ static ProcRecord drawable_offsets_proc = }; static Argument * -drawable_is_layer_invoker (Gimp *gimp, - Argument *args) +drawable_get_image_invoker (Gimp *gimp, + Argument *args) { gboolean success = TRUE; Argument *return_args; GimpDrawable *drawable; + GimpImage *gimage = NULL; drawable = (GimpDrawable *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int); if (! GIMP_IS_DRAWABLE (drawable)) success = FALSE; - return_args = procedural_db_return_args (&drawable_is_layer_proc, success); + if (success) + success = (gimage = gimp_item_get_image (GIMP_ITEM (drawable))) != NULL; + + return_args = procedural_db_return_args (&drawable_get_image_proc, success); if (success) - return_args[1].value.pdb_int = GIMP_IS_LAYER (drawable) ? TRUE : FALSE; + return_args[1].value.pdb_int = gimp_image_get_ID (gimage); return return_args; } -static ProcArg drawable_is_layer_inargs[] = +static ProcArg drawable_get_image_inargs[] = { { GIMP_PDB_DRAWABLE, @@ -1078,137 +906,81 @@ static ProcArg drawable_is_layer_inargs[] = } }; -static ProcArg drawable_is_layer_outargs[] = +static ProcArg drawable_get_image_outargs[] = { { - GIMP_PDB_INT32, - "layer", - "Non-zero if the drawable is a layer" + GIMP_PDB_IMAGE, + "image", + "The drawable's image" } }; -static ProcRecord drawable_is_layer_proc = +static ProcRecord drawable_get_image_proc = { - "gimp_drawable_is_layer", - "Returns whether the drawable is a layer.", - "This procedure returns non-zero if the specified drawable is a layer.", + "gimp_drawable_get_image", + "Returns the drawable's image.", + "This procedure returns the drawable's image.", "Spencer Kimball & Peter Mattis", "Spencer Kimball & Peter Mattis", "1995-1996", GIMP_INTERNAL, 1, - drawable_is_layer_inargs, + drawable_get_image_inargs, 1, - drawable_is_layer_outargs, - { { drawable_is_layer_invoker } } + drawable_get_image_outargs, + { { drawable_get_image_invoker } } }; static Argument * -drawable_is_layer_mask_invoker (Gimp *gimp, - Argument *args) +drawable_set_image_invoker (Gimp *gimp, + Argument *args) { gboolean success = TRUE; - Argument *return_args; GimpDrawable *drawable; + GimpImage *gimage; drawable = (GimpDrawable *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int); if (! GIMP_IS_DRAWABLE (drawable)) success = FALSE; - return_args = procedural_db_return_args (&drawable_is_layer_mask_proc, success); - - if (success) - return_args[1].value.pdb_int = GIMP_IS_LAYER_MASK (drawable) ? TRUE : FALSE; - - return return_args; -} - -static ProcArg drawable_is_layer_mask_inargs[] = -{ - { - GIMP_PDB_DRAWABLE, - "drawable", - "The drawable" - } -}; - -static ProcArg drawable_is_layer_mask_outargs[] = -{ - { - GIMP_PDB_INT32, - "layer_mask", - "Non-zero if the drawable is a layer mask" - } -}; - -static ProcRecord drawable_is_layer_mask_proc = -{ - "gimp_drawable_is_layer_mask", - "Returns whether the drawable is a layer mask.", - "This procedure returns non-zero if the specified drawable is a layer mask.", - "Spencer Kimball & Peter Mattis", - "Spencer Kimball & Peter Mattis", - "1995-1996", - GIMP_INTERNAL, - 1, - drawable_is_layer_mask_inargs, - 1, - drawable_is_layer_mask_outargs, - { { drawable_is_layer_mask_invoker } } -}; - -static Argument * -drawable_is_channel_invoker (Gimp *gimp, - Argument *args) -{ - gboolean success = TRUE; - Argument *return_args; - GimpDrawable *drawable; - - drawable = (GimpDrawable *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int); - if (! GIMP_IS_DRAWABLE (drawable)) + gimage = gimp_image_get_by_ID (gimp, args[1].value.pdb_int); + if (! GIMP_IS_IMAGE (gimage)) success = FALSE; - return_args = procedural_db_return_args (&drawable_is_channel_proc, success); - if (success) - return_args[1].value.pdb_int = GIMP_IS_CHANNEL (drawable) ? TRUE : FALSE; + gimp_item_set_image (GIMP_ITEM (drawable), gimage); - return return_args; + return procedural_db_return_args (&drawable_set_image_proc, success); } -static ProcArg drawable_is_channel_inargs[] = +static ProcArg drawable_set_image_inargs[] = { { GIMP_PDB_DRAWABLE, "drawable", "The drawable" - } -}; - -static ProcArg drawable_is_channel_outargs[] = -{ + }, { - GIMP_PDB_INT32, - "channel", - "Non-zero if the drawable is a channel" + GIMP_PDB_IMAGE, + "image", + "The image" } }; -static ProcRecord drawable_is_channel_proc = +static ProcRecord drawable_set_image_proc = { - "gimp_drawable_is_channel", - "Returns whether the drawable is a channel.", - "This procedure returns non-zero if the specified drawable is a channel.", + "gimp_drawable_set_image", + "Set image where drawable belongs to.", + "Set the image the drawable should be a part of (Use this before adding a drawable to another image).", "Spencer Kimball & Peter Mattis", "Spencer Kimball & Peter Mattis", "1995-1996", GIMP_INTERNAL, - 1, - drawable_is_channel_inargs, - 1, - drawable_is_channel_outargs, - { { drawable_is_channel_invoker } } + 2, + drawable_set_image_inargs, + 0, + NULL, + { { drawable_set_image_invoker } } }; static Argument * @@ -1631,6 +1403,229 @@ static ProcRecord drawable_set_tattoo_proc = { { drawable_set_tattoo_invoker } } }; +static Argument * +drawable_mask_bounds_invoker (Gimp *gimp, + Argument *args) +{ + gboolean success = TRUE; + Argument *return_args; + GimpDrawable *drawable; + gboolean non_empty = FALSE; + gint32 x1; + gint32 y1; + gint32 x2; + gint32 y2; + + drawable = (GimpDrawable *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int); + if (! GIMP_IS_DRAWABLE (drawable)) + success = FALSE; + + if (success) + non_empty = gimp_drawable_mask_bounds (drawable, &x1, &y1, &x2, &y2); + + return_args = procedural_db_return_args (&drawable_mask_bounds_proc, success); + + if (success) + { + return_args[1].value.pdb_int = non_empty; + return_args[2].value.pdb_int = x1; + return_args[3].value.pdb_int = y1; + return_args[4].value.pdb_int = x2; + return_args[5].value.pdb_int = y2; + } + + return return_args; +} + +static ProcArg drawable_mask_bounds_inargs[] = +{ + { + GIMP_PDB_DRAWABLE, + "drawable", + "The drawable" + } +}; + +static ProcArg drawable_mask_bounds_outargs[] = +{ + { + GIMP_PDB_INT32, + "non_empty", + "TRUE if there is a selection" + }, + { + GIMP_PDB_INT32, + "x1", + "x coordinate of the upper left corner of selection bounds" + }, + { + GIMP_PDB_INT32, + "y1", + "y coordinate of the upper left corner of selection bounds" + }, + { + GIMP_PDB_INT32, + "x2", + "x coordinate of the lower right corner of selection bounds" + }, + { + GIMP_PDB_INT32, + "y2", + "y coordinate of the lower right corner of selection bounds" + } +}; + +static ProcRecord drawable_mask_bounds_proc = +{ + "gimp_drawable_mask_bounds", + "Find the bounding box of the current selection in relation to the specified drawable.", + "This procedure returns the whether there is a selection. If there is one, the upper left and lower righthand corners of its bounding box are returned. These coordinates are specified relative to the drawable's origin, and bounded by the drawable's extents. Please note that the pixel specified by the lower righthand coordinate of the bounding box is not part of the selection. The selection ends at the upper left corner of this pixel. This means the width of the selection can be calculated as (x2 - x1), its height as (y2 - y1).", + "Spencer Kimball & Peter Mattis", + "Spencer Kimball & Peter Mattis", + "1995-1996", + GIMP_INTERNAL, + 1, + drawable_mask_bounds_inargs, + 5, + drawable_mask_bounds_outargs, + { { drawable_mask_bounds_invoker } } +}; + +static Argument * +drawable_merge_shadow_invoker (Gimp *gimp, + Argument *args) +{ + gboolean success = TRUE; + GimpDrawable *drawable; + gboolean undo; + gchar *undo_desc = NULL; + + drawable = (GimpDrawable *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int); + if (! GIMP_IS_DRAWABLE (drawable)) + success = FALSE; + + undo = args[1].value.pdb_int ? TRUE : FALSE; + + if (success) + { + if (gimp->current_plug_in) + undo_desc = plug_in_get_undo_desc (gimp->current_plug_in); + + if (! undo_desc) + undo_desc = g_strdup (_("Plug-In")); + + gimp_drawable_merge_shadow (drawable, undo, undo_desc); + + g_free (undo_desc); + } + + return procedural_db_return_args (&drawable_merge_shadow_proc, success); +} + +static ProcArg drawable_merge_shadow_inargs[] = +{ + { + GIMP_PDB_DRAWABLE, + "drawable", + "The drawable" + }, + { + GIMP_PDB_INT32, + "undo", + "Push merge to undo stack?" + } +}; + +static ProcRecord drawable_merge_shadow_proc = +{ + "gimp_drawable_merge_shadow", + "Merge the shadow buffer with the specified drawable.", + "This procedure combines the contents of the image's shadow buffer (for temporary processing) with the specified drawable. The \"undo\" parameter specifies whether to add an undo step for the operation. Requesting no undo is useful for such applications as 'auto-apply'.", + "Spencer Kimball & Peter Mattis", + "Spencer Kimball & Peter Mattis", + "1995-1996", + GIMP_INTERNAL, + 2, + drawable_merge_shadow_inargs, + 0, + NULL, + { { drawable_merge_shadow_invoker } } +}; + +static Argument * +drawable_update_invoker (Gimp *gimp, + Argument *args) +{ + gboolean success = TRUE; + GimpDrawable *drawable; + gint32 x; + gint32 y; + gint32 width; + gint32 height; + + drawable = (GimpDrawable *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int); + if (! GIMP_IS_DRAWABLE (drawable)) + success = FALSE; + + x = args[1].value.pdb_int; + + y = args[2].value.pdb_int; + + width = args[3].value.pdb_int; + + height = args[4].value.pdb_int; + + if (success) + gimp_drawable_update (drawable, x, y, width, height); + + return procedural_db_return_args (&drawable_update_proc, success); +} + +static ProcArg drawable_update_inargs[] = +{ + { + GIMP_PDB_DRAWABLE, + "drawable", + "The drawable" + }, + { + GIMP_PDB_INT32, + "x", + "x coordinate of upper left corner of update region" + }, + { + GIMP_PDB_INT32, + "y", + "y coordinate of upper left corner of update region" + }, + { + GIMP_PDB_INT32, + "width", + "Width of update region" + }, + { + GIMP_PDB_INT32, + "height", + "Height of update region" + } +}; + +static ProcRecord drawable_update_proc = +{ + "gimp_drawable_update", + "Update the specified region of the drawable.", + "This procedure updates the specified region of the drawable. The (x, y) coordinate pair is relative to the drawable's origin, not to the image origin. Therefore, the entire drawable can be updated with: {x->0, y->0, w->width, h->height }.", + "Spencer Kimball & Peter Mattis", + "Spencer Kimball & Peter Mattis", + "1995-1996", + GIMP_INTERNAL, + 5, + drawable_update_inargs, + 0, + NULL, + { { drawable_update_invoker } } +}; + static Argument * drawable_get_pixel_invoker (Gimp *gimp, Argument *args) @@ -1842,6 +1837,136 @@ static ProcRecord drawable_set_pixel_proc = { { drawable_set_pixel_invoker } } }; +static Argument * +drawable_fill_invoker (Gimp *gimp, + Argument *args) +{ + gboolean success = TRUE; + GimpDrawable *drawable; + gint32 fill_type; + + drawable = (GimpDrawable *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int); + if (! GIMP_IS_DRAWABLE (drawable)) + success = FALSE; + + fill_type = args[1].value.pdb_int; + if (fill_type < GIMP_FOREGROUND_FILL || fill_type > GIMP_NO_FILL) + success = FALSE; + + if (success) + gimp_drawable_fill_by_type (drawable, gimp_get_current_context (gimp), (GimpFillType) fill_type); + + return procedural_db_return_args (&drawable_fill_proc, success); +} + +static ProcArg drawable_fill_inargs[] = +{ + { + GIMP_PDB_DRAWABLE, + "drawable", + "The drawable" + }, + { + GIMP_PDB_INT32, + "fill_type", + "The type of fill: GIMP_FOREGROUND_FILL (0), GIMP_BACKGROUND_FILL (1), GIMP_WHITE_FILL (2), GIMP_TRANSPARENT_FILL (3), GIMP_NO_FILL (4)" + } +}; + +static ProcRecord drawable_fill_proc = +{ + "gimp_drawable_fill", + "Fill the drawable with the specified fill mode.", + "This procedure fills the drawable with the fill mode. If the fill mode is foreground the current foreground color is used. If the fill mode is background, the current background color is used. If the fill type is white, then white is used. Transparent fill only affects layers with an alpha channel, in which case the alpha channel is set to transparent. If the drawable has no alpha channel, it is filled to white. No fill leaves the drawable's contents undefined. This procedure is unlike the bucket fill tool because it fills regardless of a selection", + "Spencer Kimball & Peter Mattis", + "Spencer Kimball & Peter Mattis", + "1995-1996", + GIMP_INTERNAL, + 2, + drawable_fill_inargs, + 0, + NULL, + { { drawable_fill_invoker } } +}; + +static Argument * +drawable_offset_invoker (Gimp *gimp, + Argument *args) +{ + gboolean success = TRUE; + GimpDrawable *drawable; + gboolean wrap_around; + gint32 fill_type; + gint32 offset_x; + gint32 offset_y; + + drawable = (GimpDrawable *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int); + if (! GIMP_IS_DRAWABLE (drawable)) + success = FALSE; + + wrap_around = args[1].value.pdb_int ? TRUE : FALSE; + + fill_type = args[2].value.pdb_int; + if (fill_type < GIMP_OFFSET_BACKGROUND || fill_type > GIMP_OFFSET_TRANSPARENT) + success = FALSE; + + offset_x = args[3].value.pdb_int; + + offset_y = args[4].value.pdb_int; + + if (success) + { + gimp_drawable_offset (drawable, wrap_around, fill_type, offset_x, offset_y); + } + + return procedural_db_return_args (&drawable_offset_proc, success); +} + +static ProcArg drawable_offset_inargs[] = +{ + { + GIMP_PDB_DRAWABLE, + "drawable", + "The drawable to offset" + }, + { + GIMP_PDB_INT32, + "wrap_around", + "wrap image around or fill vacated regions" + }, + { + GIMP_PDB_INT32, + "fill_type", + "fill vacated regions of drawable with background or transparent: GIMP_OFFSET_BACKGROUND (0) or GIMP_OFFSET_TRANSPARENT (1)" + }, + { + GIMP_PDB_INT32, + "offset_x", + "offset by this amount in X direction" + }, + { + GIMP_PDB_INT32, + "offset_y", + "offset by this amount in Y direction" + } +}; + +static ProcRecord drawable_offset_proc = +{ + "gimp_drawable_offset", + "Offset the drawable by the specified amounts in the X and Y directions", + "This procedure offsets the specified drawable by the amounts specified by 'offset_x' and 'offset_y'. If 'wrap_around' is set to TRUE, then portions of the drawable which are offset out of bounds are wrapped around. Alternatively, the undefined regions of the drawable can be filled with transparency or the background color, as specified by the 'fill_type' parameter.", + "Spencer Kimball & Peter Mattis", + "Spencer Kimball & Peter Mattis", + "1997", + GIMP_INTERNAL, + 5, + drawable_offset_inargs, + 0, + NULL, + { { drawable_offset_invoker } } +}; + static Argument * drawable_thumbnail_invoker (Gimp *gimp, Argument *args) @@ -1976,128 +2101,3 @@ static ProcRecord drawable_thumbnail_proc = drawable_thumbnail_outargs, { { drawable_thumbnail_invoker } } }; - -static Argument * -drawable_offset_invoker (Gimp *gimp, - Argument *args) -{ - gboolean success = TRUE; - GimpDrawable *drawable; - gboolean wrap_around; - gint32 fill_type; - gint32 offset_x; - gint32 offset_y; - - drawable = (GimpDrawable *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int); - if (! GIMP_IS_DRAWABLE (drawable)) - success = FALSE; - - wrap_around = args[1].value.pdb_int ? TRUE : FALSE; - - fill_type = args[2].value.pdb_int; - if (fill_type < GIMP_OFFSET_BACKGROUND || fill_type > GIMP_OFFSET_TRANSPARENT) - success = FALSE; - - offset_x = args[3].value.pdb_int; - - offset_y = args[4].value.pdb_int; - - if (success) - { - gimp_drawable_offset (drawable, wrap_around, fill_type, offset_x, offset_y); - } - - return procedural_db_return_args (&drawable_offset_proc, success); -} - -static ProcArg drawable_offset_inargs[] = -{ - { - GIMP_PDB_DRAWABLE, - "drawable", - "The drawable to offset" - }, - { - GIMP_PDB_INT32, - "wrap_around", - "wrap image around or fill vacated regions" - }, - { - GIMP_PDB_INT32, - "fill_type", - "fill vacated regions of drawable with background or transparent: GIMP_OFFSET_BACKGROUND (0) or GIMP_OFFSET_TRANSPARENT (1)" - }, - { - GIMP_PDB_INT32, - "offset_x", - "offset by this amount in X direction" - }, - { - GIMP_PDB_INT32, - "offset_y", - "offset by this amount in Y direction" - } -}; - -static ProcRecord drawable_offset_proc = -{ - "gimp_drawable_offset", - "Offset the drawable by the specified amounts in the X and Y directions", - "This procedure offsets the specified drawable by the amounts specified by 'offset_x' and 'offset_y'. If 'wrap_around' is set to TRUE, then portions of the drawable which are offset out of bounds are wrapped around. Alternatively, the undefined regions of the drawable can be filled with transparency or the background color, as specified by the 'fill_type' parameter.", - "Spencer Kimball & Peter Mattis", - "Spencer Kimball & Peter Mattis", - "1997", - GIMP_INTERNAL, - 5, - drawable_offset_inargs, - 0, - NULL, - { { drawable_offset_invoker } } -}; - -static Argument * -drawable_delete_invoker (Gimp *gimp, - Argument *args) -{ - gboolean success = TRUE; - GimpDrawable *drawable; - - drawable = (GimpDrawable *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int); - if (! GIMP_IS_DRAWABLE (drawable)) - success = FALSE; - - if (success) - { - if (! gimp_item_get_image (GIMP_ITEM (drawable))) - g_object_unref (drawable); - else - success = FALSE; - } - - return procedural_db_return_args (&drawable_delete_proc, success); -} - -static ProcArg drawable_delete_inargs[] = -{ - { - GIMP_PDB_DRAWABLE, - "drawable", - "The drawable to delete" - } -}; - -static ProcRecord drawable_delete_proc = -{ - "gimp_drawable_delete", - "Delete a drawable.", - "This procedure deletes the specified drawable. This must not be done if the gimage containing this drawable was already deleted or if the drawable was already removed from the image. The only case in which this procedure is useful is if you want to get rid of a drawable which has not yet been added to an image.", - "Spencer Kimball & Peter Mattis", - "Spencer Kimball & Peter Mattis", - "1995-1996", - GIMP_INTERNAL, - 1, - drawable_delete_inargs, - 0, - NULL, - { { drawable_delete_invoker } } -}; diff --git a/app/pdb/image_cmds.c b/app/pdb/image_cmds.c index 91b34067eb..edb1462cf2 100644 --- a/app/pdb/image_cmds.c +++ b/app/pdb/image_cmds.c @@ -55,45 +55,43 @@ static ProcRecord image_list_proc; static ProcRecord image_new_proc; +static ProcRecord image_duplicate_proc; static ProcRecord image_delete_proc; static ProcRecord image_base_type_proc; +static ProcRecord image_width_proc; +static ProcRecord image_height_proc; +static ProcRecord image_free_shadow_proc; static ProcRecord image_resize_proc; static ProcRecord image_scale_proc; static ProcRecord image_crop_proc; static ProcRecord image_flip_proc; -static ProcRecord image_free_shadow_proc; static ProcRecord image_get_layers_proc; static ProcRecord image_get_channels_proc; static ProcRecord image_active_drawable_proc; static ProcRecord image_unset_active_channel_proc; +static ProcRecord image_get_floating_sel_proc; +static ProcRecord image_floating_sel_attached_to_proc; static ProcRecord image_pick_correlate_layer_proc; +static ProcRecord image_add_layer_proc; +static ProcRecord image_remove_layer_proc; static ProcRecord image_raise_layer_proc; static ProcRecord image_lower_layer_proc; static ProcRecord image_raise_layer_to_top_proc; static ProcRecord image_lower_layer_to_bottom_proc; -static ProcRecord image_merge_visible_layers_proc; -static ProcRecord image_merge_down_proc; -static ProcRecord image_flatten_proc; -static ProcRecord image_add_layer_proc; -static ProcRecord image_remove_layer_proc; -static ProcRecord image_add_layer_mask_proc; -static ProcRecord image_remove_layer_mask_proc; -static ProcRecord image_raise_channel_proc; -static ProcRecord image_lower_channel_proc; static ProcRecord image_add_channel_proc; static ProcRecord image_remove_channel_proc; +static ProcRecord image_raise_channel_proc; +static ProcRecord image_lower_channel_proc; +static ProcRecord image_flatten_proc; +static ProcRecord image_merge_visible_layers_proc; +static ProcRecord image_merge_down_proc; +static ProcRecord image_add_layer_mask_proc; +static ProcRecord image_remove_layer_mask_proc; static ProcRecord image_get_cmap_proc; static ProcRecord image_set_cmap_proc; static ProcRecord image_clean_all_proc; static ProcRecord image_is_dirty_proc; -static ProcRecord image_get_floating_sel_proc; -static ProcRecord image_floating_sel_attached_to_proc; static ProcRecord image_thumbnail_proc; -static ProcRecord image_set_tattoo_state_proc; -static ProcRecord image_get_tattoo_state_proc; -static ProcRecord image_duplicate_proc; -static ProcRecord image_width_proc; -static ProcRecord image_height_proc; static ProcRecord image_get_active_layer_proc; static ProcRecord image_set_active_layer_proc; static ProcRecord image_get_active_channel_proc; @@ -110,6 +108,8 @@ static ProcRecord image_get_resolution_proc; static ProcRecord image_set_resolution_proc; static ProcRecord image_get_unit_proc; static ProcRecord image_set_unit_proc; +static ProcRecord image_get_tattoo_state_proc; +static ProcRecord image_set_tattoo_state_proc; static ProcRecord image_get_layer_by_tattoo_proc; static ProcRecord image_get_channel_by_tattoo_proc; @@ -118,45 +118,43 @@ register_image_procs (Gimp *gimp) { procedural_db_register (gimp, &image_list_proc); procedural_db_register (gimp, &image_new_proc); + procedural_db_register (gimp, &image_duplicate_proc); procedural_db_register (gimp, &image_delete_proc); procedural_db_register (gimp, &image_base_type_proc); + procedural_db_register (gimp, &image_width_proc); + procedural_db_register (gimp, &image_height_proc); + procedural_db_register (gimp, &image_free_shadow_proc); procedural_db_register (gimp, &image_resize_proc); procedural_db_register (gimp, &image_scale_proc); procedural_db_register (gimp, &image_crop_proc); procedural_db_register (gimp, &image_flip_proc); - procedural_db_register (gimp, &image_free_shadow_proc); procedural_db_register (gimp, &image_get_layers_proc); procedural_db_register (gimp, &image_get_channels_proc); procedural_db_register (gimp, &image_active_drawable_proc); procedural_db_register (gimp, &image_unset_active_channel_proc); + procedural_db_register (gimp, &image_get_floating_sel_proc); + procedural_db_register (gimp, &image_floating_sel_attached_to_proc); procedural_db_register (gimp, &image_pick_correlate_layer_proc); + procedural_db_register (gimp, &image_add_layer_proc); + procedural_db_register (gimp, &image_remove_layer_proc); procedural_db_register (gimp, &image_raise_layer_proc); procedural_db_register (gimp, &image_lower_layer_proc); procedural_db_register (gimp, &image_raise_layer_to_top_proc); procedural_db_register (gimp, &image_lower_layer_to_bottom_proc); - procedural_db_register (gimp, &image_merge_visible_layers_proc); - procedural_db_register (gimp, &image_merge_down_proc); - procedural_db_register (gimp, &image_flatten_proc); - procedural_db_register (gimp, &image_add_layer_proc); - procedural_db_register (gimp, &image_remove_layer_proc); - procedural_db_register (gimp, &image_add_layer_mask_proc); - procedural_db_register (gimp, &image_remove_layer_mask_proc); - procedural_db_register (gimp, &image_raise_channel_proc); - procedural_db_register (gimp, &image_lower_channel_proc); procedural_db_register (gimp, &image_add_channel_proc); procedural_db_register (gimp, &image_remove_channel_proc); + procedural_db_register (gimp, &image_raise_channel_proc); + procedural_db_register (gimp, &image_lower_channel_proc); + procedural_db_register (gimp, &image_flatten_proc); + procedural_db_register (gimp, &image_merge_visible_layers_proc); + procedural_db_register (gimp, &image_merge_down_proc); + procedural_db_register (gimp, &image_add_layer_mask_proc); + procedural_db_register (gimp, &image_remove_layer_mask_proc); procedural_db_register (gimp, &image_get_cmap_proc); procedural_db_register (gimp, &image_set_cmap_proc); procedural_db_register (gimp, &image_clean_all_proc); procedural_db_register (gimp, &image_is_dirty_proc); - procedural_db_register (gimp, &image_get_floating_sel_proc); - procedural_db_register (gimp, &image_floating_sel_attached_to_proc); procedural_db_register (gimp, &image_thumbnail_proc); - procedural_db_register (gimp, &image_set_tattoo_state_proc); - procedural_db_register (gimp, &image_get_tattoo_state_proc); - procedural_db_register (gimp, &image_duplicate_proc); - procedural_db_register (gimp, &image_width_proc); - procedural_db_register (gimp, &image_height_proc); procedural_db_register (gimp, &image_get_active_layer_proc); procedural_db_register (gimp, &image_set_active_layer_proc); procedural_db_register (gimp, &image_get_active_channel_proc); @@ -173,6 +171,8 @@ register_image_procs (Gimp *gimp) procedural_db_register (gimp, &image_set_resolution_proc); procedural_db_register (gimp, &image_get_unit_proc); procedural_db_register (gimp, &image_set_unit_proc); + procedural_db_register (gimp, &image_get_tattoo_state_proc); + procedural_db_register (gimp, &image_set_tattoo_state_proc); procedural_db_register (gimp, &image_get_layer_by_tattoo_proc); procedural_db_register (gimp, &image_get_channel_by_tattoo_proc); } @@ -338,6 +338,64 @@ static ProcRecord image_new_proc = { { image_new_invoker } } }; +static Argument * +image_duplicate_invoker (Gimp *gimp, + Argument *args) +{ + gboolean success = TRUE; + Argument *return_args; + GimpImage *gimage; + GimpImage *new_image = NULL; + + gimage = gimp_image_get_by_ID (gimp, args[0].value.pdb_int); + if (! GIMP_IS_IMAGE (gimage)) + success = FALSE; + + if (success) + success = (new_image = gimp_image_duplicate (gimage)) != NULL; + + return_args = procedural_db_return_args (&image_duplicate_proc, success); + + if (success) + return_args[1].value.pdb_int = gimp_image_get_ID (new_image); + + return return_args; +} + +static ProcArg image_duplicate_inargs[] = +{ + { + GIMP_PDB_IMAGE, + "image", + "The image" + } +}; + +static ProcArg image_duplicate_outargs[] = +{ + { + GIMP_PDB_IMAGE, + "new_image", + "The new, duplicated image" + } +}; + +static ProcRecord image_duplicate_proc = +{ + "gimp_image_duplicate", + "Duplicate the specified image", + "This procedure duplicates the specified image, copying all layers, channels, and image information.", + "Spencer Kimball & Peter Mattis", + "Spencer Kimball & Peter Mattis", + "1997", + GIMP_INTERNAL, + 1, + image_duplicate_inargs, + 1, + image_duplicate_outargs, + { { image_duplicate_invoker } } +}; + static Argument * image_delete_invoker (Gimp *gimp, Argument *args) @@ -443,6 +501,156 @@ static ProcRecord image_base_type_proc = { { image_base_type_invoker } } }; +static Argument * +image_width_invoker (Gimp *gimp, + Argument *args) +{ + gboolean success = TRUE; + Argument *return_args; + GimpImage *gimage; + + gimage = gimp_image_get_by_ID (gimp, args[0].value.pdb_int); + if (! GIMP_IS_IMAGE (gimage)) + success = FALSE; + + return_args = procedural_db_return_args (&image_width_proc, success); + + if (success) + return_args[1].value.pdb_int = gimage->width; + + return return_args; +} + +static ProcArg image_width_inargs[] = +{ + { + GIMP_PDB_IMAGE, + "image", + "The image" + } +}; + +static ProcArg image_width_outargs[] = +{ + { + GIMP_PDB_INT32, + "width", + "The image's width" + } +}; + +static ProcRecord image_width_proc = +{ + "gimp_image_width", + "Return the width of the image", + "This procedure returns the image's width. This value is independent of any of the layers in this image. This is the \"canvas\" width.", + "Spencer Kimball & Peter Mattis", + "Spencer Kimball & Peter Mattis", + "1995-1996", + GIMP_INTERNAL, + 1, + image_width_inargs, + 1, + image_width_outargs, + { { image_width_invoker } } +}; + +static Argument * +image_height_invoker (Gimp *gimp, + Argument *args) +{ + gboolean success = TRUE; + Argument *return_args; + GimpImage *gimage; + + gimage = gimp_image_get_by_ID (gimp, args[0].value.pdb_int); + if (! GIMP_IS_IMAGE (gimage)) + success = FALSE; + + return_args = procedural_db_return_args (&image_height_proc, success); + + if (success) + return_args[1].value.pdb_int = gimage->height; + + return return_args; +} + +static ProcArg image_height_inargs[] = +{ + { + GIMP_PDB_IMAGE, + "image", + "The image" + } +}; + +static ProcArg image_height_outargs[] = +{ + { + GIMP_PDB_INT32, + "height", + "The image's height" + } +}; + +static ProcRecord image_height_proc = +{ + "gimp_image_height", + "Return the height of the image", + "This procedure returns the image's height. This value is independent of any of the layers in this image. This is the \"canvas\" height.", + "Spencer Kimball & Peter Mattis", + "Spencer Kimball & Peter Mattis", + "1995-1996", + GIMP_INTERNAL, + 1, + image_height_inargs, + 1, + image_height_outargs, + { { image_height_invoker } } +}; + +static Argument * +image_free_shadow_invoker (Gimp *gimp, + Argument *args) +{ + gboolean success = TRUE; + GimpImage *gimage; + + gimage = gimp_image_get_by_ID (gimp, args[0].value.pdb_int); + if (! GIMP_IS_IMAGE (gimage)) + success = FALSE; + + if (success) + gimp_image_free_shadow (gimage); + + return procedural_db_return_args (&image_free_shadow_proc, success); +} + +static ProcArg image_free_shadow_inargs[] = +{ + { + GIMP_PDB_IMAGE, + "image", + "The image" + } +}; + +static ProcRecord image_free_shadow_proc = +{ + "gimp_image_free_shadow", + "Free the specified image's shadow data (if it exists).", + "This procedure is intended as a memory saving device. If any shadow memory has been allocated, it will be freed automatically on a call to 'gimp_image_delete'.", + "Spencer Kimball & Peter Mattis", + "Spencer Kimball & Peter Mattis", + "1995-1996", + GIMP_INTERNAL, + 1, + image_free_shadow_inargs, + 0, + NULL, + { { image_free_shadow_invoker } } +}; + static Argument * image_resize_invoker (Gimp *gimp, Argument *args) @@ -734,48 +942,6 @@ static ProcRecord image_flip_proc = { { image_flip_invoker } } }; -static Argument * -image_free_shadow_invoker (Gimp *gimp, - Argument *args) -{ - gboolean success = TRUE; - GimpImage *gimage; - - gimage = gimp_image_get_by_ID (gimp, args[0].value.pdb_int); - if (! GIMP_IS_IMAGE (gimage)) - success = FALSE; - - if (success) - gimp_image_free_shadow (gimage); - - return procedural_db_return_args (&image_free_shadow_proc, success); -} - -static ProcArg image_free_shadow_inargs[] = -{ - { - GIMP_PDB_IMAGE, - "image", - "The image" - } -}; - -static ProcRecord image_free_shadow_proc = -{ - "gimp_image_free_shadow", - "Free the specified image's shadow data (if it exists).", - "This procedure is intended as a memory saving device. If any shadow memory has been allocated, it will be freed automatically on a call to 'gimp_image_delete'.", - "Spencer Kimball & Peter Mattis", - "Spencer Kimball & Peter Mattis", - "1995-1996", - GIMP_INTERNAL, - 1, - image_free_shadow_inargs, - 0, - NULL, - { { image_free_shadow_invoker } } -}; - static Argument * image_get_layers_invoker (Gimp *gimp, Argument *args) @@ -1034,6 +1200,130 @@ static ProcRecord image_unset_active_channel_proc = { { image_unset_active_channel_invoker } } }; +static Argument * +image_get_floating_sel_invoker (Gimp *gimp, + Argument *args) +{ + gboolean success = TRUE; + Argument *return_args; + GimpImage *gimage; + GimpLayer *floating_sel = NULL; + + gimage = gimp_image_get_by_ID (gimp, args[0].value.pdb_int); + if (! GIMP_IS_IMAGE (gimage)) + success = FALSE; + + if (success) + floating_sel = gimp_image_floating_sel (gimage); + + return_args = procedural_db_return_args (&image_get_floating_sel_proc, success); + + if (success) + return_args[1].value.pdb_int = floating_sel ? gimp_item_get_ID (GIMP_ITEM (floating_sel)) : -1; + + return return_args; +} + +static ProcArg image_get_floating_sel_inargs[] = +{ + { + GIMP_PDB_IMAGE, + "image", + "The image" + } +}; + +static ProcArg image_get_floating_sel_outargs[] = +{ + { + GIMP_PDB_LAYER, + "floating_sel", + "The image's floating selection" + } +}; + +static ProcRecord image_get_floating_sel_proc = +{ + "gimp_image_get_floating_sel", + "Return the floating selection of the image.", + "This procedure returns the image's floating selection, if it exists. If it doesn't exist, -1 is returned as the layer ID.", + "Spencer Kimball & Peter Mattis", + "Spencer Kimball & Peter Mattis", + "1995-1996", + GIMP_INTERNAL, + 1, + image_get_floating_sel_inargs, + 1, + image_get_floating_sel_outargs, + { { image_get_floating_sel_invoker } } +}; + +static Argument * +image_floating_sel_attached_to_invoker (Gimp *gimp, + Argument *args) +{ + gboolean success = TRUE; + Argument *return_args; + GimpImage *gimage; + GimpDrawable *drawable = NULL; + GimpLayer *floating_sel; + + gimage = gimp_image_get_by_ID (gimp, args[0].value.pdb_int); + if (! GIMP_IS_IMAGE (gimage)) + success = FALSE; + + if (success) + { + floating_sel = gimp_image_floating_sel (gimage); + + if (floating_sel) + drawable = GIMP_DRAWABLE (GIMP_LAYER (floating_sel)->fs.drawable); + else + drawable = NULL; + } + + return_args = procedural_db_return_args (&image_floating_sel_attached_to_proc, success); + + if (success) + return_args[1].value.pdb_int = drawable ? gimp_item_get_ID (GIMP_ITEM (drawable)) : -1; + + return return_args; +} + +static ProcArg image_floating_sel_attached_to_inargs[] = +{ + { + GIMP_PDB_IMAGE, + "image", + "The image" + } +}; + +static ProcArg image_floating_sel_attached_to_outargs[] = +{ + { + GIMP_PDB_DRAWABLE, + "drawable", + "The drawable the floating selection is attached to" + } +}; + +static ProcRecord image_floating_sel_attached_to_proc = +{ + "gimp_image_floating_sel_attached_to", + "Return the drawable the floating selection is attached to.", + "This procedure returns the drawable the image's floating selection is attached to, if it exists. If it doesn't exist, -1 is returned as the drawable ID.", + "Wolfgang Hofer", + "Wolfgang Hofer", + "1998", + GIMP_INTERNAL, + 1, + image_floating_sel_attached_to_inargs, + 1, + image_floating_sel_attached_to_outargs, + { { image_floating_sel_attached_to_invoker } } +}; + static Argument * image_pick_correlate_layer_invoker (Gimp *gimp, Argument *args) @@ -1108,6 +1398,128 @@ static ProcRecord image_pick_correlate_layer_proc = { { image_pick_correlate_layer_invoker } } }; +static Argument * +image_add_layer_invoker (Gimp *gimp, + Argument *args) +{ + gboolean success = TRUE; + GimpImage *gimage; + GimpLayer *layer; + gint32 position; + + gimage = gimp_image_get_by_ID (gimp, args[0].value.pdb_int); + if (! GIMP_IS_IMAGE (gimage)) + success = FALSE; + + layer = (GimpLayer *) gimp_item_get_by_ID (gimp, args[1].value.pdb_int); + if (! GIMP_IS_LAYER (layer)) + success = FALSE; + + position = args[2].value.pdb_int; + + if (success) + { + if (GIMP_IMAGE_TYPE_BASE_TYPE (gimp_drawable_type (GIMP_DRAWABLE (layer))) != + gimp_image_base_type (gimage)) + { + success = FALSE; + } + else + { + success = gimp_image_add_layer (gimage, layer, MAX (position, -1)); + } + } + + return procedural_db_return_args (&image_add_layer_proc, success); +} + +static ProcArg image_add_layer_inargs[] = +{ + { + GIMP_PDB_IMAGE, + "image", + "The image" + }, + { + GIMP_PDB_LAYER, + "layer", + "The layer" + }, + { + GIMP_PDB_INT32, + "position", + "The layer position" + } +}; + +static ProcRecord image_add_layer_proc = +{ + "gimp_image_add_layer", + "Add the specified layer to the image.", + "This procedure adds the specified layer to the gimage at the given position. If the position is specified as -1, then the layer is inserted at the top of the layer stack. If the layer to be added has no alpha channel, it must be added at position 0. The layer type must be compatible with the image base type.", + "Spencer Kimball & Peter Mattis", + "Spencer Kimball & Peter Mattis", + "1995-1996", + GIMP_INTERNAL, + 3, + image_add_layer_inargs, + 0, + NULL, + { { image_add_layer_invoker } } +}; + +static Argument * +image_remove_layer_invoker (Gimp *gimp, + Argument *args) +{ + gboolean success = TRUE; + GimpImage *gimage; + GimpLayer *layer; + + gimage = gimp_image_get_by_ID (gimp, args[0].value.pdb_int); + if (! GIMP_IS_IMAGE (gimage)) + success = FALSE; + + layer = (GimpLayer *) gimp_item_get_by_ID (gimp, args[1].value.pdb_int); + if (! GIMP_IS_LAYER (layer)) + success = FALSE; + + if (success) + gimp_image_remove_layer (gimage, layer); + + return procedural_db_return_args (&image_remove_layer_proc, success); +} + +static ProcArg image_remove_layer_inargs[] = +{ + { + GIMP_PDB_IMAGE, + "image", + "The image" + }, + { + GIMP_PDB_LAYER, + "layer", + "The layer" + } +}; + +static ProcRecord image_remove_layer_proc = +{ + "gimp_image_remove_layer", + "Remove the specified layer from the image.", + "This procedure removes the specified layer from the image. If the layer doesn't exist, an error is returned. If there are no layers left in the image, this call will fail. If this layer is the last layer remaining, the image will become empty and have no active layer.", + "Spencer Kimball & Peter Mattis", + "Spencer Kimball & Peter Mattis", + "1995-1996", + GIMP_INTERNAL, + 2, + image_remove_layer_inargs, + 0, + NULL, + { { image_remove_layer_invoker } } +}; + static Argument * image_raise_layer_invoker (Gimp *gimp, Argument *args) @@ -1316,6 +1728,280 @@ static ProcRecord image_lower_layer_to_bottom_proc = { { image_lower_layer_to_bottom_invoker } } }; +static Argument * +image_add_channel_invoker (Gimp *gimp, + Argument *args) +{ + gboolean success = TRUE; + GimpImage *gimage; + GimpChannel *channel; + gint32 position; + + gimage = gimp_image_get_by_ID (gimp, args[0].value.pdb_int); + if (! GIMP_IS_IMAGE (gimage)) + success = FALSE; + + channel = (GimpChannel *) gimp_item_get_by_ID (gimp, args[1].value.pdb_int); + if (! GIMP_IS_CHANNEL (channel)) + success = FALSE; + + position = args[2].value.pdb_int; + + if (success) + success = gimp_image_add_channel (gimage, channel, MAX (position, -1)); + + return procedural_db_return_args (&image_add_channel_proc, success); +} + +static ProcArg image_add_channel_inargs[] = +{ + { + GIMP_PDB_IMAGE, + "image", + "The image" + }, + { + GIMP_PDB_CHANNEL, + "channel", + "The channel" + }, + { + GIMP_PDB_INT32, + "position", + "The channel position" + } +}; + +static ProcRecord image_add_channel_proc = +{ + "gimp_image_add_channel", + "Add the specified channel to the image.", + "This procedure adds the specified channel to the image. The position channel is not currently used, so the channel is always inserted at the top of the channel stack.", + "Spencer Kimball & Peter Mattis", + "Spencer Kimball & Peter Mattis", + "1995-1996", + GIMP_INTERNAL, + 3, + image_add_channel_inargs, + 0, + NULL, + { { image_add_channel_invoker } } +}; + +static Argument * +image_remove_channel_invoker (Gimp *gimp, + Argument *args) +{ + gboolean success = TRUE; + GimpImage *gimage; + GimpChannel *channel; + + gimage = gimp_image_get_by_ID (gimp, args[0].value.pdb_int); + if (! GIMP_IS_IMAGE (gimage)) + success = FALSE; + + channel = (GimpChannel *) gimp_item_get_by_ID (gimp, args[1].value.pdb_int); + if (! GIMP_IS_CHANNEL (channel)) + success = FALSE; + + if (success) + gimp_image_remove_channel (gimage, channel); + + return procedural_db_return_args (&image_remove_channel_proc, success); +} + +static ProcArg image_remove_channel_inargs[] = +{ + { + GIMP_PDB_IMAGE, + "image", + "The image" + }, + { + GIMP_PDB_CHANNEL, + "channel", + "The channel" + } +}; + +static ProcRecord image_remove_channel_proc = +{ + "gimp_image_remove_channel", + "Remove the specified channel from the image.", + "This procedure removes the specified channel from the image. If the channel doesn't exist, an error is returned.", + "Spencer Kimball & Peter Mattis", + "Spencer Kimball & Peter Mattis", + "1995-1996", + GIMP_INTERNAL, + 2, + image_remove_channel_inargs, + 0, + NULL, + { { image_remove_channel_invoker } } +}; + +static Argument * +image_raise_channel_invoker (Gimp *gimp, + Argument *args) +{ + gboolean success = TRUE; + GimpImage *gimage; + GimpChannel *channel; + + gimage = gimp_image_get_by_ID (gimp, args[0].value.pdb_int); + if (! GIMP_IS_IMAGE (gimage)) + success = FALSE; + + channel = (GimpChannel *) gimp_item_get_by_ID (gimp, args[1].value.pdb_int); + if (! GIMP_IS_CHANNEL (channel)) + success = FALSE; + + if (success) + success = gimp_image_raise_channel (gimage, channel); + + return procedural_db_return_args (&image_raise_channel_proc, success); +} + +static ProcArg image_raise_channel_inargs[] = +{ + { + GIMP_PDB_IMAGE, + "image", + "The image" + }, + { + GIMP_PDB_CHANNEL, + "channel", + "The channel to raise" + } +}; + +static ProcRecord image_raise_channel_proc = +{ + "gimp_image_raise_channel", + "Raise the specified channel in the image's channel stack", + "This procedure raises the specified channel one step in the existing channel stack. It will not move the channel if there is no channel above it.", + "Spencer Kimball & Peter Mattis", + "Spencer Kimball & Peter Mattis", + "1995-1996", + GIMP_INTERNAL, + 2, + image_raise_channel_inargs, + 0, + NULL, + { { image_raise_channel_invoker } } +}; + +static Argument * +image_lower_channel_invoker (Gimp *gimp, + Argument *args) +{ + gboolean success = TRUE; + GimpImage *gimage; + GimpLayer *layer; + + gimage = gimp_image_get_by_ID (gimp, args[0].value.pdb_int); + if (! GIMP_IS_IMAGE (gimage)) + success = FALSE; + + layer = (GimpLayer *) gimp_item_get_by_ID (gimp, args[1].value.pdb_int); + if (! GIMP_IS_LAYER (layer)) + success = FALSE; + + if (success) + success = gimp_image_lower_layer (gimage, layer); + + return procedural_db_return_args (&image_lower_channel_proc, success); +} + +static ProcArg image_lower_channel_inargs[] = +{ + { + GIMP_PDB_IMAGE, + "image", + "The image" + }, + { + GIMP_PDB_LAYER, + "layer", + "The layer to lower" + } +}; + +static ProcRecord image_lower_channel_proc = +{ + "gimp_image_lower_channel", + "Lower the specified layer in the image's layer stack", + "This procedure lowers the specified layer one step in the existing layer stack. It will not move the layer if there is no layer below it, or the layer has no alpha channel.", + "Spencer Kimball & Peter Mattis", + "Spencer Kimball & Peter Mattis", + "1995-1996", + GIMP_INTERNAL, + 2, + image_lower_channel_inargs, + 0, + NULL, + { { image_lower_channel_invoker } } +}; + +static Argument * +image_flatten_invoker (Gimp *gimp, + Argument *args) +{ + gboolean success = TRUE; + Argument *return_args; + GimpImage *gimage; + GimpLayer *layer = NULL; + + gimage = gimp_image_get_by_ID (gimp, args[0].value.pdb_int); + if (! GIMP_IS_IMAGE (gimage)) + success = FALSE; + + if (success) + success = (layer = gimp_image_flatten (gimage)) != NULL; + + return_args = procedural_db_return_args (&image_flatten_proc, success); + + if (success) + return_args[1].value.pdb_int = gimp_item_get_ID (GIMP_ITEM (layer)); + + return return_args; +} + +static ProcArg image_flatten_inargs[] = +{ + { + GIMP_PDB_IMAGE, + "image", + "The image" + } +}; + +static ProcArg image_flatten_outargs[] = +{ + { + GIMP_PDB_LAYER, + "layer", + "The resulting layer" + } +}; + +static ProcRecord image_flatten_proc = +{ + "gimp_image_flatten", + "Flatten all visible layers into a single layer. Discard all invisible layers.", + "This procedure combines the visible layers in a manner analogous to merging with the CLIP_TO_IMAGE merge type. Non-visible layers are discarded, and the resulting image is stripped of its alpha channel.", + "Spencer Kimball & Peter Mattis", + "Spencer Kimball & Peter Mattis", + "1995-1996", + GIMP_INTERNAL, + 1, + image_flatten_inargs, + 1, + image_flatten_outargs, + { { image_flatten_invoker } } +}; + static Argument * image_merge_visible_layers_invoker (Gimp *gimp, Argument *args) @@ -1468,186 +2154,6 @@ static ProcRecord image_merge_down_proc = { { image_merge_down_invoker } } }; -static Argument * -image_flatten_invoker (Gimp *gimp, - Argument *args) -{ - gboolean success = TRUE; - Argument *return_args; - GimpImage *gimage; - GimpLayer *layer = NULL; - - gimage = gimp_image_get_by_ID (gimp, args[0].value.pdb_int); - if (! GIMP_IS_IMAGE (gimage)) - success = FALSE; - - if (success) - success = (layer = gimp_image_flatten (gimage)) != NULL; - - return_args = procedural_db_return_args (&image_flatten_proc, success); - - if (success) - return_args[1].value.pdb_int = gimp_item_get_ID (GIMP_ITEM (layer)); - - return return_args; -} - -static ProcArg image_flatten_inargs[] = -{ - { - GIMP_PDB_IMAGE, - "image", - "The image" - } -}; - -static ProcArg image_flatten_outargs[] = -{ - { - GIMP_PDB_LAYER, - "layer", - "The resulting layer" - } -}; - -static ProcRecord image_flatten_proc = -{ - "gimp_image_flatten", - "Flatten all visible layers into a single layer. Discard all invisible layers.", - "This procedure combines the visible layers in a manner analogous to merging with the CLIP_TO_IMAGE merge type. Non-visible layers are discarded, and the resulting image is stripped of its alpha channel.", - "Spencer Kimball & Peter Mattis", - "Spencer Kimball & Peter Mattis", - "1995-1996", - GIMP_INTERNAL, - 1, - image_flatten_inargs, - 1, - image_flatten_outargs, - { { image_flatten_invoker } } -}; - -static Argument * -image_add_layer_invoker (Gimp *gimp, - Argument *args) -{ - gboolean success = TRUE; - GimpImage *gimage; - GimpLayer *layer; - gint32 position; - - gimage = gimp_image_get_by_ID (gimp, args[0].value.pdb_int); - if (! GIMP_IS_IMAGE (gimage)) - success = FALSE; - - layer = (GimpLayer *) gimp_item_get_by_ID (gimp, args[1].value.pdb_int); - if (! GIMP_IS_LAYER (layer)) - success = FALSE; - - position = args[2].value.pdb_int; - - if (success) - { - if (GIMP_IMAGE_TYPE_BASE_TYPE (gimp_drawable_type (GIMP_DRAWABLE (layer))) != - gimp_image_base_type (gimage)) - { - success = FALSE; - } - else - { - success = gimp_image_add_layer (gimage, layer, MAX (position, -1)); - } - } - - return procedural_db_return_args (&image_add_layer_proc, success); -} - -static ProcArg image_add_layer_inargs[] = -{ - { - GIMP_PDB_IMAGE, - "image", - "The image" - }, - { - GIMP_PDB_LAYER, - "layer", - "The layer" - }, - { - GIMP_PDB_INT32, - "position", - "The layer position" - } -}; - -static ProcRecord image_add_layer_proc = -{ - "gimp_image_add_layer", - "Add the specified layer to the image.", - "This procedure adds the specified layer to the gimage at the given position. If the position is specified as -1, then the layer is inserted at the top of the layer stack. If the layer to be added has no alpha channel, it must be added at position 0. The layer type must be compatible with the image base type.", - "Spencer Kimball & Peter Mattis", - "Spencer Kimball & Peter Mattis", - "1995-1996", - GIMP_INTERNAL, - 3, - image_add_layer_inargs, - 0, - NULL, - { { image_add_layer_invoker } } -}; - -static Argument * -image_remove_layer_invoker (Gimp *gimp, - Argument *args) -{ - gboolean success = TRUE; - GimpImage *gimage; - GimpLayer *layer; - - gimage = gimp_image_get_by_ID (gimp, args[0].value.pdb_int); - if (! GIMP_IS_IMAGE (gimage)) - success = FALSE; - - layer = (GimpLayer *) gimp_item_get_by_ID (gimp, args[1].value.pdb_int); - if (! GIMP_IS_LAYER (layer)) - success = FALSE; - - if (success) - gimp_image_remove_layer (gimage, layer); - - return procedural_db_return_args (&image_remove_layer_proc, success); -} - -static ProcArg image_remove_layer_inargs[] = -{ - { - GIMP_PDB_IMAGE, - "image", - "The image" - }, - { - GIMP_PDB_LAYER, - "layer", - "The layer" - } -}; - -static ProcRecord image_remove_layer_proc = -{ - "gimp_image_remove_layer", - "Remove the specified layer from the image.", - "This procedure removes the specified layer from the image. If the layer doesn't exist, an error is returned. If there are no layers left in the image, this call will fail. If this layer is the last layer remaining, the image will become empty and have no active layer.", - "Spencer Kimball & Peter Mattis", - "Spencer Kimball & Peter Mattis", - "1995-1996", - GIMP_INTERNAL, - 2, - image_remove_layer_inargs, - 0, - NULL, - { { image_remove_layer_invoker } } -}; - static Argument * image_add_layer_mask_invoker (Gimp *gimp, Argument *args) @@ -1777,222 +2283,6 @@ static ProcRecord image_remove_layer_mask_proc = { { image_remove_layer_mask_invoker } } }; -static Argument * -image_raise_channel_invoker (Gimp *gimp, - Argument *args) -{ - gboolean success = TRUE; - GimpImage *gimage; - GimpChannel *channel; - - gimage = gimp_image_get_by_ID (gimp, args[0].value.pdb_int); - if (! GIMP_IS_IMAGE (gimage)) - success = FALSE; - - channel = (GimpChannel *) gimp_item_get_by_ID (gimp, args[1].value.pdb_int); - if (! GIMP_IS_CHANNEL (channel)) - success = FALSE; - - if (success) - success = gimp_image_raise_channel (gimage, channel); - - return procedural_db_return_args (&image_raise_channel_proc, success); -} - -static ProcArg image_raise_channel_inargs[] = -{ - { - GIMP_PDB_IMAGE, - "image", - "The image" - }, - { - GIMP_PDB_CHANNEL, - "channel", - "The channel to raise" - } -}; - -static ProcRecord image_raise_channel_proc = -{ - "gimp_image_raise_channel", - "Raise the specified channel in the image's channel stack", - "This procedure raises the specified channel one step in the existing channel stack. It will not move the channel if there is no channel above it.", - "Spencer Kimball & Peter Mattis", - "Spencer Kimball & Peter Mattis", - "1995-1996", - GIMP_INTERNAL, - 2, - image_raise_channel_inargs, - 0, - NULL, - { { image_raise_channel_invoker } } -}; - -static Argument * -image_lower_channel_invoker (Gimp *gimp, - Argument *args) -{ - gboolean success = TRUE; - GimpImage *gimage; - GimpLayer *layer; - - gimage = gimp_image_get_by_ID (gimp, args[0].value.pdb_int); - if (! GIMP_IS_IMAGE (gimage)) - success = FALSE; - - layer = (GimpLayer *) gimp_item_get_by_ID (gimp, args[1].value.pdb_int); - if (! GIMP_IS_LAYER (layer)) - success = FALSE; - - if (success) - success = gimp_image_lower_layer (gimage, layer); - - return procedural_db_return_args (&image_lower_channel_proc, success); -} - -static ProcArg image_lower_channel_inargs[] = -{ - { - GIMP_PDB_IMAGE, - "image", - "The image" - }, - { - GIMP_PDB_LAYER, - "layer", - "The layer to lower" - } -}; - -static ProcRecord image_lower_channel_proc = -{ - "gimp_image_lower_channel", - "Lower the specified layer in the image's layer stack", - "This procedure lowers the specified layer one step in the existing layer stack. It will not move the layer if there is no layer below it, or the layer has no alpha channel.", - "Spencer Kimball & Peter Mattis", - "Spencer Kimball & Peter Mattis", - "1995-1996", - GIMP_INTERNAL, - 2, - image_lower_channel_inargs, - 0, - NULL, - { { image_lower_channel_invoker } } -}; - -static Argument * -image_add_channel_invoker (Gimp *gimp, - Argument *args) -{ - gboolean success = TRUE; - GimpImage *gimage; - GimpChannel *channel; - gint32 position; - - gimage = gimp_image_get_by_ID (gimp, args[0].value.pdb_int); - if (! GIMP_IS_IMAGE (gimage)) - success = FALSE; - - channel = (GimpChannel *) gimp_item_get_by_ID (gimp, args[1].value.pdb_int); - if (! GIMP_IS_CHANNEL (channel)) - success = FALSE; - - position = args[2].value.pdb_int; - - if (success) - success = gimp_image_add_channel (gimage, channel, MAX (position, -1)); - - return procedural_db_return_args (&image_add_channel_proc, success); -} - -static ProcArg image_add_channel_inargs[] = -{ - { - GIMP_PDB_IMAGE, - "image", - "The image" - }, - { - GIMP_PDB_CHANNEL, - "channel", - "The channel" - }, - { - GIMP_PDB_INT32, - "position", - "The channel position" - } -}; - -static ProcRecord image_add_channel_proc = -{ - "gimp_image_add_channel", - "Add the specified channel to the image.", - "This procedure adds the specified channel to the image. The position channel is not currently used, so the channel is always inserted at the top of the channel stack.", - "Spencer Kimball & Peter Mattis", - "Spencer Kimball & Peter Mattis", - "1995-1996", - GIMP_INTERNAL, - 3, - image_add_channel_inargs, - 0, - NULL, - { { image_add_channel_invoker } } -}; - -static Argument * -image_remove_channel_invoker (Gimp *gimp, - Argument *args) -{ - gboolean success = TRUE; - GimpImage *gimage; - GimpChannel *channel; - - gimage = gimp_image_get_by_ID (gimp, args[0].value.pdb_int); - if (! GIMP_IS_IMAGE (gimage)) - success = FALSE; - - channel = (GimpChannel *) gimp_item_get_by_ID (gimp, args[1].value.pdb_int); - if (! GIMP_IS_CHANNEL (channel)) - success = FALSE; - - if (success) - gimp_image_remove_channel (gimage, channel); - - return procedural_db_return_args (&image_remove_channel_proc, success); -} - -static ProcArg image_remove_channel_inargs[] = -{ - { - GIMP_PDB_IMAGE, - "image", - "The image" - }, - { - GIMP_PDB_CHANNEL, - "channel", - "The channel" - } -}; - -static ProcRecord image_remove_channel_proc = -{ - "gimp_image_remove_channel", - "Remove the specified channel from the image.", - "This procedure removes the specified channel from the image. If the channel doesn't exist, an error is returned.", - "Spencer Kimball & Peter Mattis", - "Spencer Kimball & Peter Mattis", - "1995-1996", - GIMP_INTERNAL, - 2, - image_remove_channel_inargs, - 0, - NULL, - { { image_remove_channel_invoker } } -}; - static Argument * image_get_cmap_invoker (Gimp *gimp, Argument *args) @@ -2223,130 +2513,6 @@ static ProcRecord image_is_dirty_proc = { { image_is_dirty_invoker } } }; -static Argument * -image_get_floating_sel_invoker (Gimp *gimp, - Argument *args) -{ - gboolean success = TRUE; - Argument *return_args; - GimpImage *gimage; - GimpLayer *floating_sel = NULL; - - gimage = gimp_image_get_by_ID (gimp, args[0].value.pdb_int); - if (! GIMP_IS_IMAGE (gimage)) - success = FALSE; - - if (success) - floating_sel = gimp_image_floating_sel (gimage); - - return_args = procedural_db_return_args (&image_get_floating_sel_proc, success); - - if (success) - return_args[1].value.pdb_int = floating_sel ? gimp_item_get_ID (GIMP_ITEM (floating_sel)) : -1; - - return return_args; -} - -static ProcArg image_get_floating_sel_inargs[] = -{ - { - GIMP_PDB_IMAGE, - "image", - "The image" - } -}; - -static ProcArg image_get_floating_sel_outargs[] = -{ - { - GIMP_PDB_LAYER, - "floating_sel", - "The image's floating selection" - } -}; - -static ProcRecord image_get_floating_sel_proc = -{ - "gimp_image_get_floating_sel", - "Return the floating selection of the image.", - "This procedure returns the image's floating selection, if it exists. If it doesn't exist, -1 is returned as the layer ID.", - "Spencer Kimball & Peter Mattis", - "Spencer Kimball & Peter Mattis", - "1995-1996", - GIMP_INTERNAL, - 1, - image_get_floating_sel_inargs, - 1, - image_get_floating_sel_outargs, - { { image_get_floating_sel_invoker } } -}; - -static Argument * -image_floating_sel_attached_to_invoker (Gimp *gimp, - Argument *args) -{ - gboolean success = TRUE; - Argument *return_args; - GimpImage *gimage; - GimpDrawable *drawable = NULL; - GimpLayer *floating_sel; - - gimage = gimp_image_get_by_ID (gimp, args[0].value.pdb_int); - if (! GIMP_IS_IMAGE (gimage)) - success = FALSE; - - if (success) - { - floating_sel = gimp_image_floating_sel (gimage); - - if (floating_sel) - drawable = GIMP_DRAWABLE (GIMP_LAYER (floating_sel)->fs.drawable); - else - drawable = NULL; - } - - return_args = procedural_db_return_args (&image_floating_sel_attached_to_proc, success); - - if (success) - return_args[1].value.pdb_int = drawable ? gimp_item_get_ID (GIMP_ITEM (drawable)) : -1; - - return return_args; -} - -static ProcArg image_floating_sel_attached_to_inargs[] = -{ - { - GIMP_PDB_IMAGE, - "image", - "The image" - } -}; - -static ProcArg image_floating_sel_attached_to_outargs[] = -{ - { - GIMP_PDB_DRAWABLE, - "drawable", - "The drawable the floating selection is attached to" - } -}; - -static ProcRecord image_floating_sel_attached_to_proc = -{ - "gimp_image_floating_sel_attached_to", - "Return the drawable the floating selection is attached to.", - "This procedure returns the drawable the image's floating selection is attached to, if it exists. If it doesn't exist, -1 is returned as the drawable ID.", - "Wolfgang Hofer", - "Wolfgang Hofer", - "1998", - GIMP_INTERNAL, - 1, - image_floating_sel_attached_to_inargs, - 1, - image_floating_sel_attached_to_outargs, - { { image_floating_sel_attached_to_invoker } } -}; - static Argument * image_thumbnail_invoker (Gimp *gimp, Argument *args) @@ -2397,7 +2563,7 @@ image_thumbnail_invoker (Gimp *gimp, { num_bytes = buf->height * buf->width * buf->bytes; thumbnail_data = g_memdup (temp_buf_data (buf), num_bytes); - width = buf->width; + width = buf->width; height = buf->height; bpp = buf->bytes; @@ -2483,284 +2649,6 @@ static ProcRecord image_thumbnail_proc = { { image_thumbnail_invoker } } }; -static Argument * -image_set_tattoo_state_invoker (Gimp *gimp, - Argument *args) -{ - gboolean success = TRUE; - GimpImage *gimage; - gint32 tattoo; - - gimage = gimp_image_get_by_ID (gimp, args[0].value.pdb_int); - if (! GIMP_IS_IMAGE (gimage)) - success = FALSE; - - tattoo = args[1].value.pdb_int; - - if (success) - { - success = gimp_image_set_tattoo_state (gimage, tattoo); - } - - return procedural_db_return_args (&image_set_tattoo_state_proc, success); -} - -static ProcArg image_set_tattoo_state_inargs[] = -{ - { - GIMP_PDB_IMAGE, - "image", - "The image" - }, - { - GIMP_PDB_INT32, - "tattoo", - "The new tattoo state of the image" - } -}; - -static ProcRecord image_set_tattoo_state_proc = -{ - "gimp_image_set_tattoo_state", - "Set the tattoo state associated with the image.", - "This procedure sets the tattoo state of the image. Use only by save/load plugins that wish to preserve an images tattoo state. Using this function at other times will produce unexpected results. A full check of uniqueness of states in layers, channels and paths will be performed by this procedure and a execution failure will be returned if this fails. A failure will also be returned if the new tattoo state value is less than the maximum tattoo value from all of the tattoos from the paths,layers and channels. After the image data has been loaded and all the tattoos have been set then this is the last procedure that should be called. If effectively does a status check on the tattoo values that have been set to make sure that all is OK.", - "Andy Thomas", - "Andy Thomas", - "2000", - GIMP_INTERNAL, - 2, - image_set_tattoo_state_inargs, - 0, - NULL, - { { image_set_tattoo_state_invoker } } -}; - -static Argument * -image_get_tattoo_state_invoker (Gimp *gimp, - Argument *args) -{ - gboolean success = TRUE; - Argument *return_args; - GimpImage *gimage; - gint32 tattoo = 0; - - gimage = gimp_image_get_by_ID (gimp, args[0].value.pdb_int); - if (! GIMP_IS_IMAGE (gimage)) - success = FALSE; - - if (success) - { - tattoo = gimp_image_get_tattoo_state (gimage); - } - - return_args = procedural_db_return_args (&image_get_tattoo_state_proc, success); - - if (success) - return_args[1].value.pdb_int = tattoo; - - return return_args; -} - -static ProcArg image_get_tattoo_state_inargs[] = -{ - { - GIMP_PDB_IMAGE, - "image", - "The image" - } -}; - -static ProcArg image_get_tattoo_state_outargs[] = -{ - { - GIMP_PDB_INT32, - "tattoo", - "The tattoo state associated with the image" - } -}; - -static ProcRecord image_get_tattoo_state_proc = -{ - "gimp_image_get_tattoo_state", - "Returns the tattoo state associated with the image.", - "This procedure returns the tattoo state of the image. Use only by save/load plugins that wish to preserve an images tattoo state. Using this function at other times will produce unexpected results.", - "Andy Thomas", - "Andy Thomas", - "2000", - GIMP_INTERNAL, - 1, - image_get_tattoo_state_inargs, - 1, - image_get_tattoo_state_outargs, - { { image_get_tattoo_state_invoker } } -}; - -static Argument * -image_duplicate_invoker (Gimp *gimp, - Argument *args) -{ - gboolean success = TRUE; - Argument *return_args; - GimpImage *gimage; - GimpImage *new_image = NULL; - - gimage = gimp_image_get_by_ID (gimp, args[0].value.pdb_int); - if (! GIMP_IS_IMAGE (gimage)) - success = FALSE; - - if (success) - success = (new_image = gimp_image_duplicate (gimage)) != NULL; - - return_args = procedural_db_return_args (&image_duplicate_proc, success); - - if (success) - return_args[1].value.pdb_int = gimp_image_get_ID (new_image); - - return return_args; -} - -static ProcArg image_duplicate_inargs[] = -{ - { - GIMP_PDB_IMAGE, - "image", - "The image" - } -}; - -static ProcArg image_duplicate_outargs[] = -{ - { - GIMP_PDB_IMAGE, - "new_image", - "The new, duplicated image" - } -}; - -static ProcRecord image_duplicate_proc = -{ - "gimp_image_duplicate", - "Duplicate the specified image", - "This procedure duplicates the specified image, copying all layers, channels, and image information.", - "Spencer Kimball & Peter Mattis", - "Spencer Kimball & Peter Mattis", - "1997", - GIMP_INTERNAL, - 1, - image_duplicate_inargs, - 1, - image_duplicate_outargs, - { { image_duplicate_invoker } } -}; - -static Argument * -image_width_invoker (Gimp *gimp, - Argument *args) -{ - gboolean success = TRUE; - Argument *return_args; - GimpImage *gimage; - - gimage = gimp_image_get_by_ID (gimp, args[0].value.pdb_int); - if (! GIMP_IS_IMAGE (gimage)) - success = FALSE; - - return_args = procedural_db_return_args (&image_width_proc, success); - - if (success) - return_args[1].value.pdb_int = gimage->width; - - return return_args; -} - -static ProcArg image_width_inargs[] = -{ - { - GIMP_PDB_IMAGE, - "image", - "The image" - } -}; - -static ProcArg image_width_outargs[] = -{ - { - GIMP_PDB_INT32, - "width", - "The image's width" - } -}; - -static ProcRecord image_width_proc = -{ - "gimp_image_width", - "Return the width of the image", - "This procedure returns the image's width. This value is independent of any of the layers in this image. This is the \"canvas\" width.", - "Spencer Kimball & Peter Mattis", - "Spencer Kimball & Peter Mattis", - "1995-1996", - GIMP_INTERNAL, - 1, - image_width_inargs, - 1, - image_width_outargs, - { { image_width_invoker } } -}; - -static Argument * -image_height_invoker (Gimp *gimp, - Argument *args) -{ - gboolean success = TRUE; - Argument *return_args; - GimpImage *gimage; - - gimage = gimp_image_get_by_ID (gimp, args[0].value.pdb_int); - if (! GIMP_IS_IMAGE (gimage)) - success = FALSE; - - return_args = procedural_db_return_args (&image_height_proc, success); - - if (success) - return_args[1].value.pdb_int = gimage->height; - - return return_args; -} - -static ProcArg image_height_inargs[] = -{ - { - GIMP_PDB_IMAGE, - "image", - "The image" - } -}; - -static ProcArg image_height_outargs[] = -{ - { - GIMP_PDB_INT32, - "height", - "The image's height" - } -}; - -static ProcRecord image_height_proc = -{ - "gimp_image_height", - "Return the height of the image", - "This procedure returns the image's height. This value is independent of any of the layers in this image. This is the \"canvas\" height.", - "Spencer Kimball & Peter Mattis", - "Spencer Kimball & Peter Mattis", - "1995-1996", - GIMP_INTERNAL, - 1, - image_height_inargs, - 1, - image_height_outargs, - { { image_height_invoker } } -}; - static Argument * image_get_active_layer_invoker (Gimp *gimp, Argument *args) @@ -3585,19 +3473,18 @@ image_set_resolution_invoker (Gimp *gimp, if (success) { - if (!FINITE (xresolution) || + if (! FINITE (xresolution) || xresolution < GIMP_MIN_RESOLUTION || xresolution > GIMP_MAX_RESOLUTION || - !FINITE (yresolution) || + ! FINITE (yresolution) || yresolution < GIMP_MIN_RESOLUTION || yresolution > GIMP_MAX_RESOLUTION) { - g_message (_("Image resolution is out of bounds, " + g_message (_("Image resolution is out of bounds, " "using the default resolution instead.")); success = FALSE; } else { - gimage->xresolution = xresolution; - gimage->yresolution = yresolution; + gimp_image_set_resolution (gimage, xresolution, yresolution); } } @@ -3654,7 +3541,7 @@ image_get_unit_invoker (Gimp *gimp, return_args = procedural_db_return_args (&image_get_unit_proc, success); if (success) - return_args[1].value.pdb_int = gimage->unit; + return_args[1].value.pdb_int = gimp_image_get_unit (gimage); return return_args; } @@ -3710,7 +3597,7 @@ image_set_unit_invoker (Gimp *gimp, success = FALSE; if (success) - gimage->unit = unit; + gimp_image_set_unit (gimage, unit); return procedural_db_return_args (&image_set_unit_proc, success); } @@ -3745,6 +3632,110 @@ static ProcRecord image_set_unit_proc = { { image_set_unit_invoker } } }; +static Argument * +image_get_tattoo_state_invoker (Gimp *gimp, + Argument *args) +{ + gboolean success = TRUE; + Argument *return_args; + GimpImage *gimage; + + gimage = gimp_image_get_by_ID (gimp, args[0].value.pdb_int); + if (! GIMP_IS_IMAGE (gimage)) + success = FALSE; + + return_args = procedural_db_return_args (&image_get_tattoo_state_proc, success); + + if (success) + return_args[1].value.pdb_int = gimp_image_get_tattoo_state (gimage); + + return return_args; +} + +static ProcArg image_get_tattoo_state_inargs[] = +{ + { + GIMP_PDB_IMAGE, + "image", + "The image" + } +}; + +static ProcArg image_get_tattoo_state_outargs[] = +{ + { + GIMP_PDB_INT32, + "tattoo_state", + "The tattoo_state" + } +}; + +static ProcRecord image_get_tattoo_state_proc = +{ + "gimp_image_get_tattoo_state", + "Returns the tattoo state associated with the image.", + "This procedure returns the tattoo state of the image. Use only by save/load plugins that wish to preserve an images tattoo state. Using this function at other times will produce unexpected results.", + "Andy Thomas", + "Andy Thomas", + "2000", + GIMP_INTERNAL, + 1, + image_get_tattoo_state_inargs, + 1, + image_get_tattoo_state_outargs, + { { image_get_tattoo_state_invoker } } +}; + +static Argument * +image_set_tattoo_state_invoker (Gimp *gimp, + Argument *args) +{ + gboolean success = TRUE; + GimpImage *gimage; + gint32 tattoo_state; + + gimage = gimp_image_get_by_ID (gimp, args[0].value.pdb_int); + if (! GIMP_IS_IMAGE (gimage)) + success = FALSE; + + tattoo_state = args[1].value.pdb_int; + + if (success) + gimp_image_set_tattoo_state (gimage, tattoo_state); + + return procedural_db_return_args (&image_set_tattoo_state_proc, success); +} + +static ProcArg image_set_tattoo_state_inargs[] = +{ + { + GIMP_PDB_IMAGE, + "image", + "The image" + }, + { + GIMP_PDB_INT32, + "tattoo_state", + "The new image tattoo_state" + } +}; + +static ProcRecord image_set_tattoo_state_proc = +{ + "gimp_image_set_tattoo_state", + "Set the tattoo state associated with the image.", + "This procedure sets the tattoo state of the image. Use only by save/load plugins that wish to preserve an images tattoo state. Using this function at other times will produce unexpected results. A full check of uniqueness of states in layers, channels and paths will be performed by this procedure and a execution failure will be returned if this fails. A failure will also be returned if the new tattoo state value is less than the maximum tattoo value from all of the tattoos from the paths, layers and channels. After the image data has been loaded and all the tattoos have been set then this is the last procedure that should be called. If effectively does a status check on the tattoo values that have been set to make sure that all is OK.", + "Andy Thomas", + "Andy Thomas", + "2000", + GIMP_INTERNAL, + 2, + image_set_tattoo_state_inargs, + 0, + NULL, + { { image_set_tattoo_state_invoker } } +}; + static Argument * image_get_layer_by_tattoo_invoker (Gimp *gimp, Argument *args) diff --git a/app/pdb/layer_cmds.c b/app/pdb/layer_cmds.c index 238a65b049..743962628b 100644 --- a/app/pdb/layer_cmds.c +++ b/app/pdb/layer_cmds.c @@ -41,17 +41,17 @@ #include "pdb_glue.h" static ProcRecord layer_new_proc; +static ProcRecord layer_new_from_drawable_proc; static ProcRecord layer_copy_proc; -static ProcRecord layer_create_mask_proc; +static ProcRecord layer_add_alpha_proc; static ProcRecord layer_scale_proc; static ProcRecord layer_resize_proc; static ProcRecord layer_resize_to_image_size_proc; static ProcRecord layer_translate_proc; -static ProcRecord layer_add_alpha_proc; static ProcRecord layer_set_offsets_proc; +static ProcRecord layer_create_mask_proc; static ProcRecord layer_get_mask_proc; static ProcRecord layer_is_floating_sel_proc; -static ProcRecord layer_new_from_drawable_proc; static ProcRecord layer_get_preserve_trans_proc; static ProcRecord layer_set_preserve_trans_proc; static ProcRecord layer_get_apply_mask_proc; @@ -69,17 +69,17 @@ void register_layer_procs (Gimp *gimp) { procedural_db_register (gimp, &layer_new_proc); + procedural_db_register (gimp, &layer_new_from_drawable_proc); procedural_db_register (gimp, &layer_copy_proc); - procedural_db_register (gimp, &layer_create_mask_proc); + procedural_db_register (gimp, &layer_add_alpha_proc); procedural_db_register (gimp, &layer_scale_proc); procedural_db_register (gimp, &layer_resize_proc); procedural_db_register (gimp, &layer_resize_to_image_size_proc); procedural_db_register (gimp, &layer_translate_proc); - procedural_db_register (gimp, &layer_add_alpha_proc); procedural_db_register (gimp, &layer_set_offsets_proc); + procedural_db_register (gimp, &layer_create_mask_proc); procedural_db_register (gimp, &layer_get_mask_proc); procedural_db_register (gimp, &layer_is_floating_sel_proc); - procedural_db_register (gimp, &layer_new_from_drawable_proc); procedural_db_register (gimp, &layer_get_preserve_trans_proc); procedural_db_register (gimp, &layer_set_preserve_trans_proc); procedural_db_register (gimp, &layer_get_apply_mask_proc); @@ -219,6 +219,92 @@ static ProcRecord layer_new_proc = { { layer_new_invoker } } }; +static Argument * +layer_new_from_drawable_invoker (Gimp *gimp, + Argument *args) +{ + gboolean success = TRUE; + Argument *return_args; + GimpDrawable *drawable; + GimpImage *dest_image; + GimpLayer *layer_copy = NULL; + + drawable = (GimpDrawable *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int); + if (! GIMP_IS_DRAWABLE (drawable)) + success = FALSE; + + dest_image = gimp_image_get_by_ID (gimp, args[1].value.pdb_int); + if (! GIMP_IS_IMAGE (dest_image)) + success = FALSE; + + if (success) + { + GType new_type; + GimpItem *new_item; + + if (GIMP_IS_LAYER (drawable)) + new_type = G_TYPE_FROM_INSTANCE (drawable); + else + new_type = GIMP_TYPE_LAYER; + + if (dest_image == gimp_item_get_image (GIMP_ITEM (drawable))) + new_item = gimp_item_duplicate (GIMP_ITEM (drawable), new_type, TRUE); + else + new_item = gimp_item_convert (GIMP_ITEM (drawable), dest_image, new_type, TRUE); + + if (new_item) + layer_copy = GIMP_LAYER (new_item); + else + success = FALSE; + } + + return_args = procedural_db_return_args (&layer_new_from_drawable_proc, success); + + if (success) + return_args[1].value.pdb_int = gimp_item_get_ID (GIMP_ITEM (layer_copy)); + + return return_args; +} + +static ProcArg layer_new_from_drawable_inargs[] = +{ + { + GIMP_PDB_DRAWABLE, + "drawable", + "The source drawable from where the new layer is copied" + }, + { + GIMP_PDB_IMAGE, + "dest_image", + "The destination image to which to add the layer" + } +}; + +static ProcArg layer_new_from_drawable_outargs[] = +{ + { + GIMP_PDB_LAYER, + "layer_copy", + "The newly copied layer" + } +}; + +static ProcRecord layer_new_from_drawable_proc = +{ + "gimp_layer_new_from_drawable", + "Create a new layer by copying an existing drawable.", + "This procedure creates a new layer as a copy of the specified drawable. The new layer still needs to be added to the image, as this is not automatic. Add the new layer with the 'gimp_image_add_layer' command. Other attributes such as layer mask modes, and offsets should be set with explicit procedure calls.", + "Spencer Kimball & Peter Mattis", + "Spencer Kimball & Peter Mattis", + "1995-1996", + GIMP_INTERNAL, + 2, + layer_new_from_drawable_inargs, + 1, + layer_new_from_drawable_outargs, + { { layer_new_from_drawable_invoker } } +}; + static Argument * layer_copy_invoker (Gimp *gimp, Argument *args) @@ -286,71 +372,45 @@ static ProcRecord layer_copy_proc = }; static Argument * -layer_create_mask_invoker (Gimp *gimp, - Argument *args) +layer_add_alpha_invoker (Gimp *gimp, + Argument *args) { gboolean success = TRUE; - Argument *return_args; GimpLayer *layer; - gint32 mask_type; - GimpLayerMask *mask = NULL; layer = (GimpLayer *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int); if (! GIMP_IS_LAYER (layer)) success = FALSE; - mask_type = args[1].value.pdb_int; - if (mask_type < GIMP_ADD_WHITE_MASK || mask_type > GIMP_ADD_COPY_MASK) - success = FALSE; - if (success) - success = (mask = gimp_layer_create_mask (layer, (GimpAddMaskType) mask_type)) != NULL; + gimp_layer_add_alpha (layer); - return_args = procedural_db_return_args (&layer_create_mask_proc, success); - - if (success) - return_args[1].value.pdb_int = gimp_item_get_ID (GIMP_ITEM (mask)); - - return return_args; + return procedural_db_return_args (&layer_add_alpha_proc, success); } -static ProcArg layer_create_mask_inargs[] = +static ProcArg layer_add_alpha_inargs[] = { { GIMP_PDB_LAYER, "layer", - "The layer to which to add the mask" - }, - { - GIMP_PDB_INT32, - "mask_type", - "The type of mask: { GIMP_ADD_WHITE_MASK (0), GIMP_ADD_BLACK_MASK (1), GIMP_ADD_ALPHA_MASK (2), GIMP_ADD_ALPHA_TRANSFER_MASK (3), GIMP_ADD_SELECTION_MASK (4), GIMP_ADD_COPY_MASK (5) }" + "The layer" } }; -static ProcArg layer_create_mask_outargs[] = +static ProcRecord layer_add_alpha_proc = { - { - GIMP_PDB_CHANNEL, - "mask", - "The newly created mask" - } -}; - -static ProcRecord layer_create_mask_proc = -{ - "gimp_layer_create_mask", - "Create a layer mask for the specified specified layer.", - "This procedure creates a layer mask for the specified layer. Layer masks serve as an additional alpha channel for a layer. A number of ifferent types of masks are allowed for initialisation: completely white masks (which will leave the layer fully visible), completely black masks (which will give the layer complete transparency, the layer's already existing alpha channel (which will leave the layer fully visible, but which may be more useful than a white mask), the current selection or a grayscale copy of the layer. The layer mask still needs to be added to the layer. This can be done with a call to 'gimp_image_add_layer_mask'.", + "gimp_layer_add_alpha", + "Add an alpha channel to the layer if it doesn't already have one.", + "This procedure adds an additional component to the specified layer if it does not already possess an alpha channel. An alpha channel makes it possible to move a layer from the bottom of the layer stack and to clear and erase to transparency, instead of the background color. This transforms images of type RGB to RGBA, GRAY to GRAYA, and INDEXED to INDEXEDA.", "Spencer Kimball & Peter Mattis", "Spencer Kimball & Peter Mattis", "1995-1996", GIMP_INTERNAL, - 2, - layer_create_mask_inargs, 1, - layer_create_mask_outargs, - { { layer_create_mask_invoker } } + layer_add_alpha_inargs, + 0, + NULL, + { { layer_add_alpha_invoker } } }; static Argument * @@ -681,48 +741,6 @@ static ProcRecord layer_translate_proc = { { layer_translate_invoker } } }; -static Argument * -layer_add_alpha_invoker (Gimp *gimp, - Argument *args) -{ - gboolean success = TRUE; - GimpLayer *layer; - - layer = (GimpLayer *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int); - if (! GIMP_IS_LAYER (layer)) - success = FALSE; - - if (success) - gimp_layer_add_alpha (layer); - - return procedural_db_return_args (&layer_add_alpha_proc, success); -} - -static ProcArg layer_add_alpha_inargs[] = -{ - { - GIMP_PDB_LAYER, - "layer", - "The layer" - } -}; - -static ProcRecord layer_add_alpha_proc = -{ - "gimp_layer_add_alpha", - "Add an alpha channel to the layer if it doesn't already have one.", - "This procedure adds an additional component to the specified layer if it does not already possess an alpha channel. An alpha channel makes it possible to move a layer from the bottom of the layer stack and to clear and erase to transparency, instead of the background color. This transforms images of type RGB to RGBA, GRAY to GRAYA, and INDEXED to INDEXEDA.", - "Spencer Kimball & Peter Mattis", - "Spencer Kimball & Peter Mattis", - "1995-1996", - GIMP_INTERNAL, - 1, - layer_add_alpha_inargs, - 0, - NULL, - { { layer_add_alpha_invoker } } -}; - static Argument * layer_set_offsets_invoker (Gimp *gimp, Argument *args) @@ -812,6 +830,74 @@ static ProcRecord layer_set_offsets_proc = { { layer_set_offsets_invoker } } }; +static Argument * +layer_create_mask_invoker (Gimp *gimp, + Argument *args) +{ + gboolean success = TRUE; + Argument *return_args; + GimpLayer *layer; + gint32 mask_type; + GimpLayerMask *mask = NULL; + + layer = (GimpLayer *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int); + if (! GIMP_IS_LAYER (layer)) + success = FALSE; + + mask_type = args[1].value.pdb_int; + if (mask_type < GIMP_ADD_WHITE_MASK || mask_type > GIMP_ADD_COPY_MASK) + success = FALSE; + + if (success) + success = (mask = gimp_layer_create_mask (layer, (GimpAddMaskType) mask_type)) != NULL; + + return_args = procedural_db_return_args (&layer_create_mask_proc, success); + + if (success) + return_args[1].value.pdb_int = gimp_item_get_ID (GIMP_ITEM (mask)); + + return return_args; +} + +static ProcArg layer_create_mask_inargs[] = +{ + { + GIMP_PDB_LAYER, + "layer", + "The layer to which to add the mask" + }, + { + GIMP_PDB_INT32, + "mask_type", + "The type of mask: { GIMP_ADD_WHITE_MASK (0), GIMP_ADD_BLACK_MASK (1), GIMP_ADD_ALPHA_MASK (2), GIMP_ADD_ALPHA_TRANSFER_MASK (3), GIMP_ADD_SELECTION_MASK (4), GIMP_ADD_COPY_MASK (5) }" + } +}; + +static ProcArg layer_create_mask_outargs[] = +{ + { + GIMP_PDB_CHANNEL, + "mask", + "The newly created mask" + } +}; + +static ProcRecord layer_create_mask_proc = +{ + "gimp_layer_create_mask", + "Create a layer mask for the specified specified layer.", + "This procedure creates a layer mask for the specified layer. Layer masks serve as an additional alpha channel for a layer. A number of ifferent types of masks are allowed for initialisation: completely white masks (which will leave the layer fully visible), completely black masks (which will give the layer complete transparency, the layer's already existing alpha channel (which will leave the layer fully visible, but which may be more useful than a white mask), the current selection or a grayscale copy of the layer. The layer mask still needs to be added to the layer. This can be done with a call to 'gimp_image_add_layer_mask'.", + "Spencer Kimball & Peter Mattis", + "Spencer Kimball & Peter Mattis", + "1995-1996", + GIMP_INTERNAL, + 2, + layer_create_mask_inargs, + 1, + layer_create_mask_outargs, + { { layer_create_mask_invoker } } +}; + static Argument * layer_get_mask_invoker (Gimp *gimp, Argument *args) @@ -920,92 +1006,6 @@ static ProcRecord layer_is_floating_sel_proc = { { layer_is_floating_sel_invoker } } }; -static Argument * -layer_new_from_drawable_invoker (Gimp *gimp, - Argument *args) -{ - gboolean success = TRUE; - Argument *return_args; - GimpDrawable *drawable; - GimpImage *dest_image; - GimpLayer *layer_copy = NULL; - - drawable = (GimpDrawable *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int); - if (! GIMP_IS_DRAWABLE (drawable)) - success = FALSE; - - dest_image = gimp_image_get_by_ID (gimp, args[1].value.pdb_int); - if (! GIMP_IS_IMAGE (dest_image)) - success = FALSE; - - if (success) - { - GType new_type; - GimpItem *new_item; - - if (GIMP_IS_LAYER (drawable)) - new_type = G_TYPE_FROM_INSTANCE (drawable); - else - new_type = GIMP_TYPE_LAYER; - - if (dest_image == gimp_item_get_image (GIMP_ITEM (drawable))) - new_item = gimp_item_duplicate (GIMP_ITEM (drawable), new_type, TRUE); - else - new_item = gimp_item_convert (GIMP_ITEM (drawable), dest_image, new_type, TRUE); - - if (new_item) - layer_copy = GIMP_LAYER (new_item); - else - success = FALSE; - } - - return_args = procedural_db_return_args (&layer_new_from_drawable_proc, success); - - if (success) - return_args[1].value.pdb_int = gimp_item_get_ID (GIMP_ITEM (layer_copy)); - - return return_args; -} - -static ProcArg layer_new_from_drawable_inargs[] = -{ - { - GIMP_PDB_DRAWABLE, - "drawable", - "The source drawable from where the new layer is copied" - }, - { - GIMP_PDB_IMAGE, - "dest_image", - "The destination image to which to add the layer" - } -}; - -static ProcArg layer_new_from_drawable_outargs[] = -{ - { - GIMP_PDB_LAYER, - "layer_copy", - "The newly copied layer" - } -}; - -static ProcRecord layer_new_from_drawable_proc = -{ - "gimp_layer_new_from_drawable", - "Create a new layer by copying an existing drawable.", - "This procedure creates a new layer as a copy of the specified drawable. The new layer still needs to be added to the image, as this is not automatic. Add the new layer with the 'gimp_image_add_layer' command. Other attributes such as layer mask modes, and offsets should be set with explicit procedure calls.", - "Spencer Kimball & Peter Mattis", - "Spencer Kimball & Peter Mattis", - "1995-1996", - GIMP_INTERNAL, - 2, - layer_new_from_drawable_inargs, - 1, - layer_new_from_drawable_outargs, - { { layer_new_from_drawable_invoker } } -}; - static Argument * layer_get_preserve_trans_invoker (Gimp *gimp, Argument *args) diff --git a/app/pdb/misc_tools_cmds.c b/app/pdb/misc_tools_cmds.c index 33d73a46b4..0f2c4054ae 100644 --- a/app/pdb/misc_tools_cmds.c +++ b/app/pdb/misc_tools_cmds.c @@ -359,7 +359,7 @@ static ProcRecord bucket_fill_proc = { "gimp_bucket_fill", "Fill the area specified either by the current selection if there is one, or by a seed fill starting at the specified coordinates.", - "This tool requires information on the paint application mode, and the fill mode, which can either be in the foreground color, or in the currently active pattern. If there is no selection, a seed fill is executed at the specified coordinates and extends outward in keeping with the threshold parameter. If there is a selection in the target image, the threshold, sample merged, x, and y arguments are unused. If the sample_merged parameter is non-zero, the data of the composite image will be used instead of that for the specified drawable. This is equivalent to sampling for colors after merging all visible layers. In the case of merged sampling, the x,y coordinates are relative to the image's origin; otherwise, they are relative to the drawable's origin.", + "This tool requires information on the paint application mode, and the fill mode, which can either be in the foreground color, or in the currently active pattern. If there is no selection, a seed fill is executed at the specified coordinates and extends outward in keeping with the threshold parameter. If there is a selection in the target image, the threshold, sample merged, x, and y arguments are unused. If the sample_merged parameter is non-zero, the data of the composite image will be used instead of that for the specified drawable. This is equivalent to sampling for colors after merging all visible layers. In the case of merged sampling, the x and y coordinates are relative to the image's origin; otherwise, they are relative to the drawable's origin.", "Spencer Kimball & Peter Mattis", "Spencer Kimball & Peter Mattis", "1995-1996", @@ -482,7 +482,7 @@ static ProcRecord color_picker_proc = { "gimp_color_picker", "Determine the color at the given drawable coordinates", - "This tool determines the color at the specified coordinates. The returned color is an RGB triplet even for grayscale and indexed drawables. If the coordinates lie outside of the extents of the specified drawable, then an error is returned. If the drawable has an alpha channel, the algorithm examines the alpha value of the drawable at the coordinates. If the alpha value is completely transparent (0), then an error is returned. If the sample_merged parameter is non-zero, the data of the composite image will be used instead of that for the specified drawable. This is equivalent to sampling for colors after merging all visible layers. In the case of a merged sampling, the supplied drawable is ignored.", + "This tool determines the color at the specified coordinates. The returned color is an RGB triplet even for grayscale and indexed drawables. If the coordinates lie outside of the extents of the specified drawable, then an error is returned. If the drawable has an alpha channel, the algorithm examines the alpha value of the drawable at the coordinates. If the alpha value is completely transparent (0), then an error is returned. If the sample_merged parameter is non-zero, the data of the composite image will be used instead of that for the specified drawable. This is equivalent to sampling for colors after merging all visible layers. In the case of a merged sampling, the supplied drawable is ignored except for finding the image it belongs to.", "Spencer Kimball & Peter Mattis", "Spencer Kimball & Peter Mattis", "1995-1996", diff --git a/libgimp/gimpdrawable_pdb.c b/libgimp/gimpdrawable_pdb.c index 592c0bda6f..ba5326342a 100644 --- a/libgimp/gimpdrawable_pdb.c +++ b/libgimp/gimpdrawable_pdb.c @@ -28,31 +28,29 @@ #include "gimp.h" /** - * gimp_drawable_merge_shadow: - * @drawable_ID: The drawable. - * @undo: Push merge to undo stack? + * gimp_drawable_delete: + * @drawable_ID: The drawable to delete. * - * Merge the shadow buffer with the specified drawable. + * Delete a drawable. * - * This procedure combines the contents of the image's shadow buffer - * (for temporary processing) with the specified drawable. The \"undo\" - * parameter specifies whether to add an undo step for the operation. - * Requesting no undo is useful for such applications as 'auto-apply'. + * This procedure deletes the specified drawable. This must not be done + * if the gimage containing this drawable was already deleted or if the + * drawable was already removed from the image. The only case in which + * this procedure is useful is if you want to get rid of a drawable + * which has not yet been added to an image. * * Returns: TRUE on success. */ gboolean -gimp_drawable_merge_shadow (gint32 drawable_ID, - gboolean undo) +gimp_drawable_delete (gint32 drawable_ID) { GimpParam *return_vals; gint nreturn_vals; gboolean success = TRUE; - return_vals = gimp_run_procedure ("gimp_drawable_merge_shadow", + return_vals = gimp_run_procedure ("gimp_drawable_delete", &nreturn_vals, GIMP_PDB_DRAWABLE, drawable_ID, - GIMP_PDB_INT32, undo, GIMP_PDB_END); success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS; @@ -63,234 +61,96 @@ gimp_drawable_merge_shadow (gint32 drawable_ID, } /** - * gimp_drawable_fill: + * gimp_drawable_is_layer: * @drawable_ID: The drawable. - * @fill_type: The type of fill. * - * Fill the drawable with the specified fill mode. + * Returns whether the drawable is a layer. * - * This procedure fills the drawable with the fill mode. If the fill - * mode is foreground the current foreground color is used. If the fill - * mode is background, the current background color is used. If the - * fill type is white, then white is used. Transparent fill only - * affects layers with an alpha channel, in which case the alpha - * channel is set to transparent. If the drawable has no alpha channel, - * it is filled to white. No fill leaves the drawable's contents - * undefined. This procedure is unlike the bucket fill tool because it - * fills regardless of a selection + * This procedure returns non-zero if the specified drawable is a + * layer. * - * Returns: TRUE on success. + * Returns: Non-zero if the drawable is a layer. */ gboolean -gimp_drawable_fill (gint32 drawable_ID, - GimpFillType fill_type) +gimp_drawable_is_layer (gint32 drawable_ID) { GimpParam *return_vals; gint nreturn_vals; - gboolean success = TRUE; + gboolean layer = FALSE; - return_vals = gimp_run_procedure ("gimp_drawable_fill", - &nreturn_vals, - GIMP_PDB_DRAWABLE, drawable_ID, - GIMP_PDB_INT32, fill_type, - GIMP_PDB_END); - - success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS; - - gimp_destroy_params (return_vals, nreturn_vals); - - return success; -} - -/** - * gimp_drawable_update: - * @drawable_ID: The drawable. - * @x: x coordinate of upper left corner of update region. - * @y: y coordinate of upper left corner of update region. - * @width: Width of update region. - * @height: Height of update region. - * - * Update the specified region of the drawable. - * - * This procedure updates the specified region of the drawable. The (x, - * y) coordinate pair is relative to the drawable's origin, not to the - * image origin. Therefore, the entire drawable can be updated with: - * {x->0, y->0, w->width, h->height }. - * - * Returns: TRUE on success. - */ -gboolean -gimp_drawable_update (gint32 drawable_ID, - gint x, - gint y, - gint width, - gint height) -{ - GimpParam *return_vals; - gint nreturn_vals; - gboolean success = TRUE; - - return_vals = gimp_run_procedure ("gimp_drawable_update", - &nreturn_vals, - GIMP_PDB_DRAWABLE, drawable_ID, - GIMP_PDB_INT32, x, - GIMP_PDB_INT32, y, - GIMP_PDB_INT32, width, - GIMP_PDB_INT32, height, - GIMP_PDB_END); - - success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS; - - gimp_destroy_params (return_vals, nreturn_vals); - - return success; -} - -/** - * gimp_drawable_mask_bounds: - * @drawable_ID: The drawable. - * @x1: x coordinate of the upper left corner of selection bounds. - * @y1: y coordinate of the upper left corner of selection bounds. - * @x2: x coordinate of the lower right corner of selection bounds. - * @y2: y coordinate of the lower right corner of selection bounds. - * - * Find the bounding box of the current selection in relation to the - * specified drawable. - * - * This procedure returns the whether there is a selection. If there is - * one, the upper left and lower righthand corners of its bounding box - * are returned. These coordinates are specified relative to the - * drawable's origin, and bounded by the drawable's extents. Please - * note that the pixel specified by the lower righthand coordinate of - * the bounding box is not part of the selection. The selection ends at - * the upper left corner of this pixel. This means the width of the - * selection can be calculated as (x2 - x1), its height as (y2 - y1). - * - * Returns: TRUE if there is a selection. - */ -gboolean -gimp_drawable_mask_bounds (gint32 drawable_ID, - gint *x1, - gint *y1, - gint *x2, - gint *y2) -{ - GimpParam *return_vals; - gint nreturn_vals; - gboolean non_empty = FALSE; - - return_vals = gimp_run_procedure ("gimp_drawable_mask_bounds", + return_vals = gimp_run_procedure ("gimp_drawable_is_layer", &nreturn_vals, GIMP_PDB_DRAWABLE, drawable_ID, GIMP_PDB_END); if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS) - { - non_empty = return_vals[1].data.d_int32; - *x1 = return_vals[2].data.d_int32; - *y1 = return_vals[3].data.d_int32; - *x2 = return_vals[4].data.d_int32; - *y2 = return_vals[5].data.d_int32; - } + layer = return_vals[1].data.d_int32; gimp_destroy_params (return_vals, nreturn_vals); - return non_empty; + return layer; } /** - * gimp_drawable_get_image: + * gimp_drawable_is_layer_mask: * @drawable_ID: The drawable. * - * Returns the drawable's image. + * Returns whether the drawable is a layer mask. * - * This procedure returns the drawable's image. + * This procedure returns non-zero if the specified drawable is a layer + * mask. * - * Returns: The drawable's image. + * Returns: Non-zero if the drawable is a layer mask. */ -gint32 -gimp_drawable_get_image (gint32 drawable_ID) +gboolean +gimp_drawable_is_layer_mask (gint32 drawable_ID) { GimpParam *return_vals; gint nreturn_vals; - gint32 image_ID = -1; + gboolean layer_mask = FALSE; - return_vals = gimp_run_procedure ("gimp_drawable_get_image", + return_vals = gimp_run_procedure ("gimp_drawable_is_layer_mask", &nreturn_vals, GIMP_PDB_DRAWABLE, drawable_ID, GIMP_PDB_END); if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS) - image_ID = return_vals[1].data.d_image; + layer_mask = return_vals[1].data.d_int32; gimp_destroy_params (return_vals, nreturn_vals); - return image_ID; + return layer_mask; } /** - * gimp_drawable_set_image: + * gimp_drawable_is_channel: * @drawable_ID: The drawable. - * @image_ID: The image. * - * Set image where drawable belongs to. + * Returns whether the drawable is a channel. * - * Set the image the drawable should be a part of (Use this before - * adding a drawable to another image). + * This procedure returns non-zero if the specified drawable is a + * channel. * - * Returns: TRUE on success. + * Returns: Non-zero if the drawable is a channel. */ gboolean -gimp_drawable_set_image (gint32 drawable_ID, - gint32 image_ID) +gimp_drawable_is_channel (gint32 drawable_ID) { GimpParam *return_vals; gint nreturn_vals; - gboolean success = TRUE; + gboolean channel = FALSE; - return_vals = gimp_run_procedure ("gimp_drawable_set_image", - &nreturn_vals, - GIMP_PDB_DRAWABLE, drawable_ID, - GIMP_PDB_IMAGE, image_ID, - GIMP_PDB_END); - - success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS; - - gimp_destroy_params (return_vals, nreturn_vals); - - return success; -} - -/** - * gimp_drawable_has_alpha: - * @drawable_ID: The drawable. - * - * Returns non-zero if the drawable has an alpha channel. - * - * This procedure returns whether the specified drawable has an alpha - * channel. This can only be true for layers, and the associated type - * will be one of: { RGBA , GRAYA, INDEXEDA }. - * - * Returns: Does the drawable have an alpha channel? - */ -gboolean -gimp_drawable_has_alpha (gint32 drawable_ID) -{ - GimpParam *return_vals; - gint nreturn_vals; - gboolean has_alpha = FALSE; - - return_vals = gimp_run_procedure ("gimp_drawable_has_alpha", + return_vals = gimp_run_procedure ("gimp_drawable_is_channel", &nreturn_vals, GIMP_PDB_DRAWABLE, drawable_ID, GIMP_PDB_END); if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS) - has_alpha = return_vals[1].data.d_int32; + channel = return_vals[1].data.d_int32; gimp_destroy_params (return_vals, nreturn_vals); - return has_alpha; + return channel; } /** @@ -356,6 +216,38 @@ gimp_drawable_type_with_alpha (gint32 drawable_ID) return type_with_alpha; } +/** + * gimp_drawable_has_alpha: + * @drawable_ID: The drawable. + * + * Returns non-zero if the drawable has an alpha channel. + * + * This procedure returns whether the specified drawable has an alpha + * channel. This can only be true for layers, and the associated type + * will be one of: { RGBA , GRAYA, INDEXEDA }. + * + * Returns: Does the drawable have an alpha channel? + */ +gboolean +gimp_drawable_has_alpha (gint32 drawable_ID) +{ + GimpParam *return_vals; + gint nreturn_vals; + gboolean has_alpha = FALSE; + + return_vals = gimp_run_procedure ("gimp_drawable_has_alpha", + &nreturn_vals, + GIMP_PDB_DRAWABLE, drawable_ID, + GIMP_PDB_END); + + if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS) + has_alpha = return_vals[1].data.d_int32; + + gimp_destroy_params (return_vals, nreturn_vals); + + return has_alpha; +} + /** * gimp_drawable_is_rgb: * @drawable_ID: The drawable. @@ -585,96 +477,66 @@ gimp_drawable_offsets (gint32 drawable_ID, } /** - * gimp_drawable_is_layer: + * gimp_drawable_get_image: * @drawable_ID: The drawable. * - * Returns whether the drawable is a layer. + * Returns the drawable's image. * - * This procedure returns non-zero if the specified drawable is a - * layer. + * This procedure returns the drawable's image. * - * Returns: Non-zero if the drawable is a layer. + * Returns: The drawable's image. */ -gboolean -gimp_drawable_is_layer (gint32 drawable_ID) +gint32 +gimp_drawable_get_image (gint32 drawable_ID) { GimpParam *return_vals; gint nreturn_vals; - gboolean layer = FALSE; + gint32 image_ID = -1; - return_vals = gimp_run_procedure ("gimp_drawable_is_layer", + return_vals = gimp_run_procedure ("gimp_drawable_get_image", &nreturn_vals, GIMP_PDB_DRAWABLE, drawable_ID, GIMP_PDB_END); if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS) - layer = return_vals[1].data.d_int32; + image_ID = return_vals[1].data.d_image; gimp_destroy_params (return_vals, nreturn_vals); - return layer; + return image_ID; } /** - * gimp_drawable_is_layer_mask: + * gimp_drawable_set_image: * @drawable_ID: The drawable. + * @image_ID: The image. * - * Returns whether the drawable is a layer mask. + * Set image where drawable belongs to. * - * This procedure returns non-zero if the specified drawable is a layer - * mask. + * Set the image the drawable should be a part of (Use this before + * adding a drawable to another image). * - * Returns: Non-zero if the drawable is a layer mask. + * Returns: TRUE on success. */ gboolean -gimp_drawable_is_layer_mask (gint32 drawable_ID) +gimp_drawable_set_image (gint32 drawable_ID, + gint32 image_ID) { GimpParam *return_vals; gint nreturn_vals; - gboolean layer_mask = FALSE; + gboolean success = TRUE; - return_vals = gimp_run_procedure ("gimp_drawable_is_layer_mask", + return_vals = gimp_run_procedure ("gimp_drawable_set_image", &nreturn_vals, GIMP_PDB_DRAWABLE, drawable_ID, + GIMP_PDB_IMAGE, image_ID, GIMP_PDB_END); - if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS) - layer_mask = return_vals[1].data.d_int32; + success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS; gimp_destroy_params (return_vals, nreturn_vals); - return layer_mask; -} - -/** - * gimp_drawable_is_channel: - * @drawable_ID: The drawable. - * - * Returns whether the drawable is a channel. - * - * This procedure returns non-zero if the specified drawable is a - * channel. - * - * Returns: Non-zero if the drawable is a channel. - */ -gboolean -gimp_drawable_is_channel (gint32 drawable_ID) -{ - GimpParam *return_vals; - gint nreturn_vals; - gboolean channel = FALSE; - - return_vals = gimp_run_procedure ("gimp_drawable_is_channel", - &nreturn_vals, - GIMP_PDB_DRAWABLE, drawable_ID, - GIMP_PDB_END); - - if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS) - channel = return_vals[1].data.d_int32; - - gimp_destroy_params (return_vals, nreturn_vals); - - return channel; + return success; } /** @@ -931,6 +793,137 @@ gimp_drawable_set_tattoo (gint32 drawable_ID, return success; } +/** + * gimp_drawable_mask_bounds: + * @drawable_ID: The drawable. + * @x1: x coordinate of the upper left corner of selection bounds. + * @y1: y coordinate of the upper left corner of selection bounds. + * @x2: x coordinate of the lower right corner of selection bounds. + * @y2: y coordinate of the lower right corner of selection bounds. + * + * Find the bounding box of the current selection in relation to the + * specified drawable. + * + * This procedure returns the whether there is a selection. If there is + * one, the upper left and lower righthand corners of its bounding box + * are returned. These coordinates are specified relative to the + * drawable's origin, and bounded by the drawable's extents. Please + * note that the pixel specified by the lower righthand coordinate of + * the bounding box is not part of the selection. The selection ends at + * the upper left corner of this pixel. This means the width of the + * selection can be calculated as (x2 - x1), its height as (y2 - y1). + * + * Returns: TRUE if there is a selection. + */ +gboolean +gimp_drawable_mask_bounds (gint32 drawable_ID, + gint *x1, + gint *y1, + gint *x2, + gint *y2) +{ + GimpParam *return_vals; + gint nreturn_vals; + gboolean non_empty = FALSE; + + return_vals = gimp_run_procedure ("gimp_drawable_mask_bounds", + &nreturn_vals, + GIMP_PDB_DRAWABLE, drawable_ID, + GIMP_PDB_END); + + if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS) + { + non_empty = return_vals[1].data.d_int32; + *x1 = return_vals[2].data.d_int32; + *y1 = return_vals[3].data.d_int32; + *x2 = return_vals[4].data.d_int32; + *y2 = return_vals[5].data.d_int32; + } + + gimp_destroy_params (return_vals, nreturn_vals); + + return non_empty; +} + +/** + * gimp_drawable_merge_shadow: + * @drawable_ID: The drawable. + * @undo: Push merge to undo stack? + * + * Merge the shadow buffer with the specified drawable. + * + * This procedure combines the contents of the image's shadow buffer + * (for temporary processing) with the specified drawable. The \"undo\" + * parameter specifies whether to add an undo step for the operation. + * Requesting no undo is useful for such applications as 'auto-apply'. + * + * Returns: TRUE on success. + */ +gboolean +gimp_drawable_merge_shadow (gint32 drawable_ID, + gboolean undo) +{ + GimpParam *return_vals; + gint nreturn_vals; + gboolean success = TRUE; + + return_vals = gimp_run_procedure ("gimp_drawable_merge_shadow", + &nreturn_vals, + GIMP_PDB_DRAWABLE, drawable_ID, + GIMP_PDB_INT32, undo, + GIMP_PDB_END); + + success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS; + + gimp_destroy_params (return_vals, nreturn_vals); + + return success; +} + +/** + * gimp_drawable_update: + * @drawable_ID: The drawable. + * @x: x coordinate of upper left corner of update region. + * @y: y coordinate of upper left corner of update region. + * @width: Width of update region. + * @height: Height of update region. + * + * Update the specified region of the drawable. + * + * This procedure updates the specified region of the drawable. The (x, + * y) coordinate pair is relative to the drawable's origin, not to the + * image origin. Therefore, the entire drawable can be updated with: + * {x->0, y->0, w->width, h->height }. + * + * Returns: TRUE on success. + */ +gboolean +gimp_drawable_update (gint32 drawable_ID, + gint x, + gint y, + gint width, + gint height) +{ + GimpParam *return_vals; + gint nreturn_vals; + gboolean success = TRUE; + + return_vals = gimp_run_procedure ("gimp_drawable_update", + &nreturn_vals, + GIMP_PDB_DRAWABLE, drawable_ID, + GIMP_PDB_INT32, x, + GIMP_PDB_INT32, y, + GIMP_PDB_INT32, width, + GIMP_PDB_INT32, height, + GIMP_PDB_END); + + success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS; + + gimp_destroy_params (return_vals, nreturn_vals); + + return success; +} + /** * gimp_drawable_get_pixel: * @drawable_ID: The drawable. @@ -1023,6 +1016,93 @@ gimp_drawable_set_pixel (gint32 drawable_ID, return success; } +/** + * gimp_drawable_fill: + * @drawable_ID: The drawable. + * @fill_type: The type of fill. + * + * Fill the drawable with the specified fill mode. + * + * This procedure fills the drawable with the fill mode. If the fill + * mode is foreground the current foreground color is used. If the fill + * mode is background, the current background color is used. If the + * fill type is white, then white is used. Transparent fill only + * affects layers with an alpha channel, in which case the alpha + * channel is set to transparent. If the drawable has no alpha channel, + * it is filled to white. No fill leaves the drawable's contents + * undefined. This procedure is unlike the bucket fill tool because it + * fills regardless of a selection + * + * Returns: TRUE on success. + */ +gboolean +gimp_drawable_fill (gint32 drawable_ID, + GimpFillType fill_type) +{ + GimpParam *return_vals; + gint nreturn_vals; + gboolean success = TRUE; + + return_vals = gimp_run_procedure ("gimp_drawable_fill", + &nreturn_vals, + GIMP_PDB_DRAWABLE, drawable_ID, + GIMP_PDB_INT32, fill_type, + GIMP_PDB_END); + + success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS; + + gimp_destroy_params (return_vals, nreturn_vals); + + return success; +} + +/** + * gimp_drawable_offset: + * @drawable_ID: The drawable to offset. + * @wrap_around: wrap image around or fill vacated regions. + * @fill_type: fill vacated regions of drawable with background or transparent. + * @offset_x: offset by this amount in X direction. + * @offset_y: offset by this amount in Y direction. + * + * Offset the drawable by the specified amounts in the X and Y + * directions + * + * This procedure offsets the specified drawable by the amounts + * specified by 'offset_x' and 'offset_y'. If 'wrap_around' is set to + * TRUE, then portions of the drawable which are offset out of bounds + * are wrapped around. Alternatively, the undefined regions of the + * drawable can be filled with transparency or the background color, as + * specified by the 'fill_type' parameter. + * + * Returns: TRUE on success. + */ +gboolean +gimp_drawable_offset (gint32 drawable_ID, + gboolean wrap_around, + GimpOffsetType fill_type, + gint offset_x, + gint offset_y) +{ + GimpParam *return_vals; + gint nreturn_vals; + gboolean success = TRUE; + + return_vals = gimp_run_procedure ("gimp_drawable_offset", + &nreturn_vals, + GIMP_PDB_DRAWABLE, drawable_ID, + GIMP_PDB_INT32, wrap_around, + GIMP_PDB_INT32, fill_type, + GIMP_PDB_INT32, offset_x, + GIMP_PDB_INT32, offset_y, + GIMP_PDB_END); + + success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS; + + gimp_destroy_params (return_vals, nreturn_vals); + + return success; +} + /** * _gimp_drawable_thumbnail: * @drawable_ID: The drawable. @@ -1088,83 +1168,3 @@ _gimp_drawable_thumbnail (gint32 drawable_ID, return success; } - -/** - * gimp_drawable_offset: - * @drawable_ID: The drawable to offset. - * @wrap_around: wrap image around or fill vacated regions. - * @fill_type: fill vacated regions of drawable with background or transparent. - * @offset_x: offset by this amount in X direction. - * @offset_y: offset by this amount in Y direction. - * - * Offset the drawable by the specified amounts in the X and Y - * directions - * - * This procedure offsets the specified drawable by the amounts - * specified by 'offset_x' and 'offset_y'. If 'wrap_around' is set to - * TRUE, then portions of the drawable which are offset out of bounds - * are wrapped around. Alternatively, the undefined regions of the - * drawable can be filled with transparency or the background color, as - * specified by the 'fill_type' parameter. - * - * Returns: TRUE on success. - */ -gboolean -gimp_drawable_offset (gint32 drawable_ID, - gboolean wrap_around, - GimpOffsetType fill_type, - gint offset_x, - gint offset_y) -{ - GimpParam *return_vals; - gint nreturn_vals; - gboolean success = TRUE; - - return_vals = gimp_run_procedure ("gimp_drawable_offset", - &nreturn_vals, - GIMP_PDB_DRAWABLE, drawable_ID, - GIMP_PDB_INT32, wrap_around, - GIMP_PDB_INT32, fill_type, - GIMP_PDB_INT32, offset_x, - GIMP_PDB_INT32, offset_y, - GIMP_PDB_END); - - success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS; - - gimp_destroy_params (return_vals, nreturn_vals); - - return success; -} - -/** - * gimp_drawable_delete: - * @drawable_ID: The drawable to delete. - * - * Delete a drawable. - * - * This procedure deletes the specified drawable. This must not be done - * if the gimage containing this drawable was already deleted or if the - * drawable was already removed from the image. The only case in which - * this procedure is useful is if you want to get rid of a drawable - * which has not yet been added to an image. - * - * Returns: TRUE on success. - */ -gboolean -gimp_drawable_delete (gint32 drawable_ID) -{ - GimpParam *return_vals; - gint nreturn_vals; - gboolean success = TRUE; - - return_vals = gimp_run_procedure ("gimp_drawable_delete", - &nreturn_vals, - GIMP_PDB_DRAWABLE, drawable_ID, - GIMP_PDB_END); - - success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS; - - gimp_destroy_params (return_vals, nreturn_vals); - - return success; -} diff --git a/libgimp/gimpdrawable_pdb.h b/libgimp/gimpdrawable_pdb.h index fc36734168..e2ba758b57 100644 --- a/libgimp/gimpdrawable_pdb.h +++ b/libgimp/gimpdrawable_pdb.h @@ -29,26 +29,13 @@ G_BEGIN_DECLS /* For information look into the C source or the html documentation */ -gboolean gimp_drawable_merge_shadow (gint32 drawable_ID, - gboolean undo); -gboolean gimp_drawable_fill (gint32 drawable_ID, - GimpFillType fill_type); -gboolean gimp_drawable_update (gint32 drawable_ID, - gint x, - gint y, - gint width, - gint height); -gboolean gimp_drawable_mask_bounds (gint32 drawable_ID, - gint *x1, - gint *y1, - gint *x2, - gint *y2); -gint32 gimp_drawable_get_image (gint32 drawable_ID); -gboolean gimp_drawable_set_image (gint32 drawable_ID, - gint32 image_ID); -gboolean gimp_drawable_has_alpha (gint32 drawable_ID); +gboolean gimp_drawable_delete (gint32 drawable_ID); +gboolean gimp_drawable_is_layer (gint32 drawable_ID); +gboolean gimp_drawable_is_layer_mask (gint32 drawable_ID); +gboolean gimp_drawable_is_channel (gint32 drawable_ID); GimpImageType gimp_drawable_type (gint32 drawable_ID); GimpImageType gimp_drawable_type_with_alpha (gint32 drawable_ID); +gboolean gimp_drawable_has_alpha (gint32 drawable_ID); gboolean gimp_drawable_is_rgb (gint32 drawable_ID); gboolean gimp_drawable_is_gray (gint32 drawable_ID); gboolean gimp_drawable_is_indexed (gint32 drawable_ID); @@ -58,9 +45,9 @@ gint gimp_drawable_height (gint32 drawable_ID); gboolean gimp_drawable_offsets (gint32 drawable_ID, gint *offset_x, gint *offset_y); -gboolean gimp_drawable_is_layer (gint32 drawable_ID); -gboolean gimp_drawable_is_layer_mask (gint32 drawable_ID); -gboolean gimp_drawable_is_channel (gint32 drawable_ID); +gint32 gimp_drawable_get_image (gint32 drawable_ID); +gboolean gimp_drawable_set_image (gint32 drawable_ID, + gint32 image_ID); gchar* gimp_drawable_get_name (gint32 drawable_ID); gboolean gimp_drawable_set_name (gint32 drawable_ID, const gchar *name); @@ -73,6 +60,18 @@ gboolean gimp_drawable_set_linked (gint32 drawable_ID, gint gimp_drawable_get_tattoo (gint32 drawable_ID); gboolean gimp_drawable_set_tattoo (gint32 drawable_ID, gint tattoo); +gboolean gimp_drawable_mask_bounds (gint32 drawable_ID, + gint *x1, + gint *y1, + gint *x2, + gint *y2); +gboolean gimp_drawable_merge_shadow (gint32 drawable_ID, + gboolean undo); +gboolean gimp_drawable_update (gint32 drawable_ID, + gint x, + gint y, + gint width, + gint height); guint8* gimp_drawable_get_pixel (gint32 drawable_ID, gint x_coord, gint y_coord, @@ -82,6 +81,13 @@ gboolean gimp_drawable_set_pixel (gint32 drawable_ID, gint y_coord, gint num_channels, const guint8 *pixel); +gboolean gimp_drawable_fill (gint32 drawable_ID, + GimpFillType fill_type); +gboolean gimp_drawable_offset (gint32 drawable_ID, + gboolean wrap_around, + GimpOffsetType fill_type, + gint offset_x, + gint offset_y); gboolean _gimp_drawable_thumbnail (gint32 drawable_ID, gint width, gint height, @@ -90,12 +96,6 @@ gboolean _gimp_drawable_thumbnail (gint32 drawable_ID, gint *bpp, gint *thumbnail_data_count, guint8 **thumbnail_data); -gboolean gimp_drawable_offset (gint32 drawable_ID, - gboolean wrap_around, - GimpOffsetType fill_type, - gint offset_x, - gint offset_y); -gboolean gimp_drawable_delete (gint32 drawable_ID); G_END_DECLS diff --git a/libgimp/gimpimage_pdb.c b/libgimp/gimpimage_pdb.c index 3dbd7682e9..906b8b77ba 100644 --- a/libgimp/gimpimage_pdb.c +++ b/libgimp/gimpimage_pdb.c @@ -105,6 +105,37 @@ gimp_image_new (gint width, return image_ID; } +/** + * gimp_image_duplicate: + * @image_ID: The image. + * + * Duplicate the specified image + * + * This procedure duplicates the specified image, copying all layers, + * channels, and image information. + * + * Returns: The new, duplicated image. + */ +gint32 +gimp_image_duplicate (gint32 image_ID) +{ + GimpParam *return_vals; + gint nreturn_vals; + gint32 new_image_ID = -1; + + return_vals = gimp_run_procedure ("gimp_image_duplicate", + &nreturn_vals, + GIMP_PDB_IMAGE, image_ID, + GIMP_PDB_END); + + if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS) + new_image_ID = return_vals[1].data.d_image; + + gimp_destroy_params (return_vals, nreturn_vals); + + return new_image_ID; +} + /** * gimp_image_delete: * @image_ID: The image. @@ -170,6 +201,99 @@ gimp_image_base_type (gint32 image_ID) return base_type; } +/** + * gimp_image_width: + * @image_ID: The image. + * + * Return the width of the image + * + * This procedure returns the image's width. This value is independent + * of any of the layers in this image. This is the \"canvas\" width. + * + * Returns: The image's width. + */ +gint +gimp_image_width (gint32 image_ID) +{ + GimpParam *return_vals; + gint nreturn_vals; + gint width = 0; + + return_vals = gimp_run_procedure ("gimp_image_width", + &nreturn_vals, + GIMP_PDB_IMAGE, image_ID, + GIMP_PDB_END); + + if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS) + width = return_vals[1].data.d_int32; + + gimp_destroy_params (return_vals, nreturn_vals); + + return width; +} + +/** + * gimp_image_height: + * @image_ID: The image. + * + * Return the height of the image + * + * This procedure returns the image's height. This value is independent + * of any of the layers in this image. This is the \"canvas\" height. + * + * Returns: The image's height. + */ +gint +gimp_image_height (gint32 image_ID) +{ + GimpParam *return_vals; + gint nreturn_vals; + gint height = 0; + + return_vals = gimp_run_procedure ("gimp_image_height", + &nreturn_vals, + GIMP_PDB_IMAGE, image_ID, + GIMP_PDB_END); + + if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS) + height = return_vals[1].data.d_int32; + + gimp_destroy_params (return_vals, nreturn_vals); + + return height; +} + +/** + * gimp_image_free_shadow: + * @image_ID: The image. + * + * Free the specified image's shadow data (if it exists). + * + * This procedure is intended as a memory saving device. If any shadow + * memory has been allocated, it will be freed automatically on a call + * to 'gimp_image_delete'. + * + * Returns: TRUE on success. + */ +gboolean +gimp_image_free_shadow (gint32 image_ID) +{ + GimpParam *return_vals; + gint nreturn_vals; + gboolean success = TRUE; + + return_vals = gimp_run_procedure ("gimp_image_free_shadow", + &nreturn_vals, + GIMP_PDB_IMAGE, image_ID, + GIMP_PDB_END); + + success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS; + + gimp_destroy_params (return_vals, nreturn_vals); + + return success; +} + /** * gimp_image_resize: * @image_ID: The image. @@ -338,37 +462,6 @@ gimp_image_flip (gint32 image_ID, return success; } -/** - * gimp_image_free_shadow: - * @image_ID: The image. - * - * Free the specified image's shadow data (if it exists). - * - * This procedure is intended as a memory saving device. If any shadow - * memory has been allocated, it will be freed automatically on a call - * to 'gimp_image_delete'. - * - * Returns: TRUE on success. - */ -gboolean -gimp_image_free_shadow (gint32 image_ID) -{ - GimpParam *return_vals; - gint nreturn_vals; - gboolean success = TRUE; - - return_vals = gimp_run_procedure ("gimp_image_free_shadow", - &nreturn_vals, - GIMP_PDB_IMAGE, image_ID, - GIMP_PDB_END); - - success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS; - - gimp_destroy_params (return_vals, nreturn_vals); - - return success; -} - /** * gimp_image_get_layers: * @image_ID: The image. @@ -517,6 +610,69 @@ gimp_image_unset_active_channel (gint32 image_ID) return success; } +/** + * gimp_image_get_floating_sel: + * @image_ID: The image. + * + * Return the floating selection of the image. + * + * This procedure returns the image's floating selection, if it exists. + * If it doesn't exist, -1 is returned as the layer ID. + * + * Returns: The image's floating selection. + */ +gint32 +gimp_image_get_floating_sel (gint32 image_ID) +{ + GimpParam *return_vals; + gint nreturn_vals; + gint32 floating_sel_ID = -1; + + return_vals = gimp_run_procedure ("gimp_image_get_floating_sel", + &nreturn_vals, + GIMP_PDB_IMAGE, image_ID, + GIMP_PDB_END); + + if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS) + floating_sel_ID = return_vals[1].data.d_layer; + + gimp_destroy_params (return_vals, nreturn_vals); + + return floating_sel_ID; +} + +/** + * gimp_image_floating_sel_attached_to: + * @image_ID: The image. + * + * Return the drawable the floating selection is attached to. + * + * This procedure returns the drawable the image's floating selection + * is attached to, if it exists. If it doesn't exist, -1 is returned as + * the drawable ID. + * + * Returns: The drawable the floating selection is attached to. + */ +gint32 +gimp_image_floating_sel_attached_to (gint32 image_ID) +{ + GimpParam *return_vals; + gint nreturn_vals; + gint32 drawable_ID = -1; + + return_vals = gimp_run_procedure ("gimp_image_floating_sel_attached_to", + &nreturn_vals, + GIMP_PDB_IMAGE, image_ID, + GIMP_PDB_END); + + if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS) + drawable_ID = return_vals[1].data.d_drawable; + + gimp_destroy_params (return_vals, nreturn_vals); + + return drawable_ID; +} + /** * gimp_image_pick_correlate_layer: * @image_ID: The image. @@ -557,6 +713,81 @@ gimp_image_pick_correlate_layer (gint32 image_ID, return layer_ID; } +/** + * gimp_image_add_layer: + * @image_ID: The image. + * @layer_ID: The layer. + * @position: The layer position. + * + * Add the specified layer to the image. + * + * This procedure adds the specified layer to the gimage at the given + * position. If the position is specified as -1, then the layer is + * inserted at the top of the layer stack. If the layer to be added has + * no alpha channel, it must be added at position 0. The layer type + * must be compatible with the image base type. + * + * Returns: TRUE on success. + */ +gboolean +gimp_image_add_layer (gint32 image_ID, + gint32 layer_ID, + gint position) +{ + GimpParam *return_vals; + gint nreturn_vals; + gboolean success = TRUE; + + return_vals = gimp_run_procedure ("gimp_image_add_layer", + &nreturn_vals, + GIMP_PDB_IMAGE, image_ID, + GIMP_PDB_LAYER, layer_ID, + GIMP_PDB_INT32, position, + GIMP_PDB_END); + + success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS; + + gimp_destroy_params (return_vals, nreturn_vals); + + return success; +} + +/** + * gimp_image_remove_layer: + * @image_ID: The image. + * @layer_ID: The layer. + * + * Remove the specified layer from the image. + * + * This procedure removes the specified layer from the image. If the + * layer doesn't exist, an error is returned. If there are no layers + * left in the image, this call will fail. If this layer is the last + * layer remaining, the image will become empty and have no active + * layer. + * + * Returns: TRUE on success. + */ +gboolean +gimp_image_remove_layer (gint32 image_ID, + gint32 layer_ID) +{ + GimpParam *return_vals; + gint nreturn_vals; + gboolean success = TRUE; + + return_vals = gimp_run_procedure ("gimp_image_remove_layer", + &nreturn_vals, + GIMP_PDB_IMAGE, image_ID, + GIMP_PDB_LAYER, layer_ID, + GIMP_PDB_END); + + success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS; + + gimp_destroy_params (return_vals, nreturn_vals); + + return success; +} + /** * gimp_image_raise_layer: * @image_ID: The image. @@ -694,6 +925,177 @@ gimp_image_lower_layer_to_bottom (gint32 image_ID, return success; } +/** + * gimp_image_add_channel: + * @image_ID: The image. + * @channel_ID: The channel. + * @position: The channel position. + * + * Add the specified channel to the image. + * + * This procedure adds the specified channel to the image. The position + * channel is not currently used, so the channel is always inserted at + * the top of the channel stack. + * + * Returns: TRUE on success. + */ +gboolean +gimp_image_add_channel (gint32 image_ID, + gint32 channel_ID, + gint position) +{ + GimpParam *return_vals; + gint nreturn_vals; + gboolean success = TRUE; + + return_vals = gimp_run_procedure ("gimp_image_add_channel", + &nreturn_vals, + GIMP_PDB_IMAGE, image_ID, + GIMP_PDB_CHANNEL, channel_ID, + GIMP_PDB_INT32, position, + GIMP_PDB_END); + + success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS; + + gimp_destroy_params (return_vals, nreturn_vals); + + return success; +} + +/** + * gimp_image_remove_channel: + * @image_ID: The image. + * @channel_ID: The channel. + * + * Remove the specified channel from the image. + * + * This procedure removes the specified channel from the image. If the + * channel doesn't exist, an error is returned. + * + * Returns: TRUE on success. + */ +gboolean +gimp_image_remove_channel (gint32 image_ID, + gint32 channel_ID) +{ + GimpParam *return_vals; + gint nreturn_vals; + gboolean success = TRUE; + + return_vals = gimp_run_procedure ("gimp_image_remove_channel", + &nreturn_vals, + GIMP_PDB_IMAGE, image_ID, + GIMP_PDB_CHANNEL, channel_ID, + GIMP_PDB_END); + + success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS; + + gimp_destroy_params (return_vals, nreturn_vals); + + return success; +} + +/** + * gimp_image_raise_channel: + * @image_ID: The image. + * @channel_ID: The channel to raise. + * + * Raise the specified channel in the image's channel stack + * + * This procedure raises the specified channel one step in the existing + * channel stack. It will not move the channel if there is no channel + * above it. + * + * Returns: TRUE on success. + */ +gboolean +gimp_image_raise_channel (gint32 image_ID, + gint32 channel_ID) +{ + GimpParam *return_vals; + gint nreturn_vals; + gboolean success = TRUE; + + return_vals = gimp_run_procedure ("gimp_image_raise_channel", + &nreturn_vals, + GIMP_PDB_IMAGE, image_ID, + GIMP_PDB_CHANNEL, channel_ID, + GIMP_PDB_END); + + success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS; + + gimp_destroy_params (return_vals, nreturn_vals); + + return success; +} + +/** + * gimp_image_lower_channel: + * @image_ID: The image. + * @layer_ID: The layer to lower. + * + * Lower the specified layer in the image's layer stack + * + * This procedure lowers the specified layer one step in the existing + * layer stack. It will not move the layer if there is no layer below + * it, or the layer has no alpha channel. + * + * Returns: TRUE on success. + */ +gboolean +gimp_image_lower_channel (gint32 image_ID, + gint32 layer_ID) +{ + GimpParam *return_vals; + gint nreturn_vals; + gboolean success = TRUE; + + return_vals = gimp_run_procedure ("gimp_image_lower_channel", + &nreturn_vals, + GIMP_PDB_IMAGE, image_ID, + GIMP_PDB_LAYER, layer_ID, + GIMP_PDB_END); + + success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS; + + gimp_destroy_params (return_vals, nreturn_vals); + + return success; +} + +/** + * gimp_image_flatten: + * @image_ID: The image. + * + * Flatten all visible layers into a single layer. Discard all + * invisible layers. + * + * This procedure combines the visible layers in a manner analogous to + * merging with the CLIP_TO_IMAGE merge type. Non-visible layers are + * discarded, and the resulting image is stripped of its alpha channel. + * + * Returns: The resulting layer. + */ +gint32 +gimp_image_flatten (gint32 image_ID) +{ + GimpParam *return_vals; + gint nreturn_vals; + gint32 layer_ID = -1; + + return_vals = gimp_run_procedure ("gimp_image_flatten", + &nreturn_vals, + GIMP_PDB_IMAGE, image_ID, + GIMP_PDB_END); + + if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS) + layer_ID = return_vals[1].data.d_layer; + + gimp_destroy_params (return_vals, nreturn_vals); + + return layer_ID; +} + /** * gimp_image_merge_visible_layers: * @image_ID: The image. @@ -774,114 +1176,6 @@ gimp_image_merge_down (gint32 image_ID, return layer_ID; } -/** - * gimp_image_flatten: - * @image_ID: The image. - * - * Flatten all visible layers into a single layer. Discard all - * invisible layers. - * - * This procedure combines the visible layers in a manner analogous to - * merging with the CLIP_TO_IMAGE merge type. Non-visible layers are - * discarded, and the resulting image is stripped of its alpha channel. - * - * Returns: The resulting layer. - */ -gint32 -gimp_image_flatten (gint32 image_ID) -{ - GimpParam *return_vals; - gint nreturn_vals; - gint32 layer_ID = -1; - - return_vals = gimp_run_procedure ("gimp_image_flatten", - &nreturn_vals, - GIMP_PDB_IMAGE, image_ID, - GIMP_PDB_END); - - if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS) - layer_ID = return_vals[1].data.d_layer; - - gimp_destroy_params (return_vals, nreturn_vals); - - return layer_ID; -} - -/** - * gimp_image_add_layer: - * @image_ID: The image. - * @layer_ID: The layer. - * @position: The layer position. - * - * Add the specified layer to the image. - * - * This procedure adds the specified layer to the gimage at the given - * position. If the position is specified as -1, then the layer is - * inserted at the top of the layer stack. If the layer to be added has - * no alpha channel, it must be added at position 0. The layer type - * must be compatible with the image base type. - * - * Returns: TRUE on success. - */ -gboolean -gimp_image_add_layer (gint32 image_ID, - gint32 layer_ID, - gint position) -{ - GimpParam *return_vals; - gint nreturn_vals; - gboolean success = TRUE; - - return_vals = gimp_run_procedure ("gimp_image_add_layer", - &nreturn_vals, - GIMP_PDB_IMAGE, image_ID, - GIMP_PDB_LAYER, layer_ID, - GIMP_PDB_INT32, position, - GIMP_PDB_END); - - success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS; - - gimp_destroy_params (return_vals, nreturn_vals); - - return success; -} - -/** - * gimp_image_remove_layer: - * @image_ID: The image. - * @layer_ID: The layer. - * - * Remove the specified layer from the image. - * - * This procedure removes the specified layer from the image. If the - * layer doesn't exist, an error is returned. If there are no layers - * left in the image, this call will fail. If this layer is the last - * layer remaining, the image will become empty and have no active - * layer. - * - * Returns: TRUE on success. - */ -gboolean -gimp_image_remove_layer (gint32 image_ID, - gint32 layer_ID) -{ - GimpParam *return_vals; - gint nreturn_vals; - gboolean success = TRUE; - - return_vals = gimp_run_procedure ("gimp_image_remove_layer", - &nreturn_vals, - GIMP_PDB_IMAGE, image_ID, - GIMP_PDB_LAYER, layer_ID, - GIMP_PDB_END); - - success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS; - - gimp_destroy_params (return_vals, nreturn_vals); - - return success; -} - /** * gimp_image_add_layer_mask: * @image_ID: The image. @@ -958,144 +1252,6 @@ gimp_image_remove_layer_mask (gint32 image_ID, return success; } -/** - * gimp_image_raise_channel: - * @image_ID: The image. - * @channel_ID: The channel to raise. - * - * Raise the specified channel in the image's channel stack - * - * This procedure raises the specified channel one step in the existing - * channel stack. It will not move the channel if there is no channel - * above it. - * - * Returns: TRUE on success. - */ -gboolean -gimp_image_raise_channel (gint32 image_ID, - gint32 channel_ID) -{ - GimpParam *return_vals; - gint nreturn_vals; - gboolean success = TRUE; - - return_vals = gimp_run_procedure ("gimp_image_raise_channel", - &nreturn_vals, - GIMP_PDB_IMAGE, image_ID, - GIMP_PDB_CHANNEL, channel_ID, - GIMP_PDB_END); - - success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS; - - gimp_destroy_params (return_vals, nreturn_vals); - - return success; -} - -/** - * gimp_image_lower_channel: - * @image_ID: The image. - * @layer_ID: The layer to lower. - * - * Lower the specified layer in the image's layer stack - * - * This procedure lowers the specified layer one step in the existing - * layer stack. It will not move the layer if there is no layer below - * it, or the layer has no alpha channel. - * - * Returns: TRUE on success. - */ -gboolean -gimp_image_lower_channel (gint32 image_ID, - gint32 layer_ID) -{ - GimpParam *return_vals; - gint nreturn_vals; - gboolean success = TRUE; - - return_vals = gimp_run_procedure ("gimp_image_lower_channel", - &nreturn_vals, - GIMP_PDB_IMAGE, image_ID, - GIMP_PDB_LAYER, layer_ID, - GIMP_PDB_END); - - success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS; - - gimp_destroy_params (return_vals, nreturn_vals); - - return success; -} - -/** - * gimp_image_add_channel: - * @image_ID: The image. - * @channel_ID: The channel. - * @position: The channel position. - * - * Add the specified channel to the image. - * - * This procedure adds the specified channel to the image. The position - * channel is not currently used, so the channel is always inserted at - * the top of the channel stack. - * - * Returns: TRUE on success. - */ -gboolean -gimp_image_add_channel (gint32 image_ID, - gint32 channel_ID, - gint position) -{ - GimpParam *return_vals; - gint nreturn_vals; - gboolean success = TRUE; - - return_vals = gimp_run_procedure ("gimp_image_add_channel", - &nreturn_vals, - GIMP_PDB_IMAGE, image_ID, - GIMP_PDB_CHANNEL, channel_ID, - GIMP_PDB_INT32, position, - GIMP_PDB_END); - - success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS; - - gimp_destroy_params (return_vals, nreturn_vals); - - return success; -} - -/** - * gimp_image_remove_channel: - * @image_ID: The image. - * @channel_ID: The channel. - * - * Remove the specified channel from the image. - * - * This procedure removes the specified channel from the image. If the - * channel doesn't exist, an error is returned. - * - * Returns: TRUE on success. - */ -gboolean -gimp_image_remove_channel (gint32 image_ID, - gint32 channel_ID) -{ - GimpParam *return_vals; - gint nreturn_vals; - gboolean success = TRUE; - - return_vals = gimp_run_procedure ("gimp_image_remove_channel", - &nreturn_vals, - GIMP_PDB_IMAGE, image_ID, - GIMP_PDB_CHANNEL, channel_ID, - GIMP_PDB_END); - - success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS; - - gimp_destroy_params (return_vals, nreturn_vals); - - return success; -} - /** * _gimp_image_get_cmap: * @image_ID: The image. @@ -1242,69 +1398,6 @@ gimp_image_is_dirty (gint32 image_ID) return dirty; } -/** - * gimp_image_get_floating_sel: - * @image_ID: The image. - * - * Return the floating selection of the image. - * - * This procedure returns the image's floating selection, if it exists. - * If it doesn't exist, -1 is returned as the layer ID. - * - * Returns: The image's floating selection. - */ -gint32 -gimp_image_get_floating_sel (gint32 image_ID) -{ - GimpParam *return_vals; - gint nreturn_vals; - gint32 floating_sel_ID = -1; - - return_vals = gimp_run_procedure ("gimp_image_get_floating_sel", - &nreturn_vals, - GIMP_PDB_IMAGE, image_ID, - GIMP_PDB_END); - - if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS) - floating_sel_ID = return_vals[1].data.d_layer; - - gimp_destroy_params (return_vals, nreturn_vals); - - return floating_sel_ID; -} - -/** - * gimp_image_floating_sel_attached_to: - * @image_ID: The image. - * - * Return the drawable the floating selection is attached to. - * - * This procedure returns the drawable the image's floating selection - * is attached to, if it exists. If it doesn't exist, -1 is returned as - * the drawable ID. - * - * Returns: The drawable the floating selection is attached to. - */ -gint32 -gimp_image_floating_sel_attached_to (gint32 image_ID) -{ - GimpParam *return_vals; - gint nreturn_vals; - gint32 drawable_ID = -1; - - return_vals = gimp_run_procedure ("gimp_image_floating_sel_attached_to", - &nreturn_vals, - GIMP_PDB_IMAGE, image_ID, - GIMP_PDB_END); - - if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS) - drawable_ID = return_vals[1].data.d_drawable; - - gimp_destroy_params (return_vals, nreturn_vals); - - return drawable_ID; -} - /** * _gimp_image_thumbnail: * @image_ID: The image. @@ -1371,174 +1464,6 @@ _gimp_image_thumbnail (gint32 image_ID, return success; } -/** - * gimp_image_set_tattoo_state: - * @image_ID: The image. - * @tattoo: The new tattoo state of the image. - * - * Set the tattoo state associated with the image. - * - * This procedure sets the tattoo state of the image. Use only by - * save/load plugins that wish to preserve an images tattoo state. - * Using this function at other times will produce unexpected results. - * A full check of uniqueness of states in layers, channels and paths - * will be performed by this procedure and a execution failure will be - * returned if this fails. A failure will also be returned if the new - * tattoo state value is less than the maximum tattoo value from all of - * the tattoos from the paths,layers and channels. After the image data - * has been loaded and all the tattoos have been set then this is the - * last procedure that should be called. If effectively does a status - * check on the tattoo values that have been set to make sure that all - * is OK. - * - * Returns: TRUE on success. - */ -gboolean -gimp_image_set_tattoo_state (gint32 image_ID, - gint tattoo) -{ - GimpParam *return_vals; - gint nreturn_vals; - gboolean success = TRUE; - - return_vals = gimp_run_procedure ("gimp_image_set_tattoo_state", - &nreturn_vals, - GIMP_PDB_IMAGE, image_ID, - GIMP_PDB_INT32, tattoo, - GIMP_PDB_END); - - success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS; - - gimp_destroy_params (return_vals, nreturn_vals); - - return success; -} - -/** - * gimp_image_get_tattoo_state: - * @image_ID: The image. - * - * Returns the tattoo state associated with the image. - * - * This procedure returns the tattoo state of the image. Use only by - * save/load plugins that wish to preserve an images tattoo state. - * Using this function at other times will produce unexpected results. - * - * Returns: The tattoo state associated with the image. - */ -gint -gimp_image_get_tattoo_state (gint32 image_ID) -{ - GimpParam *return_vals; - gint nreturn_vals; - gint tattoo = 0; - - return_vals = gimp_run_procedure ("gimp_image_get_tattoo_state", - &nreturn_vals, - GIMP_PDB_IMAGE, image_ID, - GIMP_PDB_END); - - if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS) - tattoo = return_vals[1].data.d_int32; - - gimp_destroy_params (return_vals, nreturn_vals); - - return tattoo; -} - -/** - * gimp_image_duplicate: - * @image_ID: The image. - * - * Duplicate the specified image - * - * This procedure duplicates the specified image, copying all layers, - * channels, and image information. - * - * Returns: The new, duplicated image. - */ -gint32 -gimp_image_duplicate (gint32 image_ID) -{ - GimpParam *return_vals; - gint nreturn_vals; - gint32 new_image_ID = -1; - - return_vals = gimp_run_procedure ("gimp_image_duplicate", - &nreturn_vals, - GIMP_PDB_IMAGE, image_ID, - GIMP_PDB_END); - - if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS) - new_image_ID = return_vals[1].data.d_image; - - gimp_destroy_params (return_vals, nreturn_vals); - - return new_image_ID; -} - -/** - * gimp_image_width: - * @image_ID: The image. - * - * Return the width of the image - * - * This procedure returns the image's width. This value is independent - * of any of the layers in this image. This is the \"canvas\" width. - * - * Returns: The image's width. - */ -gint -gimp_image_width (gint32 image_ID) -{ - GimpParam *return_vals; - gint nreturn_vals; - gint width = 0; - - return_vals = gimp_run_procedure ("gimp_image_width", - &nreturn_vals, - GIMP_PDB_IMAGE, image_ID, - GIMP_PDB_END); - - if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS) - width = return_vals[1].data.d_int32; - - gimp_destroy_params (return_vals, nreturn_vals); - - return width; -} - -/** - * gimp_image_height: - * @image_ID: The image. - * - * Return the height of the image - * - * This procedure returns the image's height. This value is independent - * of any of the layers in this image. This is the \"canvas\" height. - * - * Returns: The image's height. - */ -gint -gimp_image_height (gint32 image_ID) -{ - GimpParam *return_vals; - gint nreturn_vals; - gint height = 0; - - return_vals = gimp_run_procedure ("gimp_image_height", - &nreturn_vals, - GIMP_PDB_IMAGE, image_ID, - GIMP_PDB_END); - - if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS) - height = return_vals[1].data.d_int32; - - gimp_destroy_params (return_vals, nreturn_vals); - - return height; -} - /** * gimp_image_get_active_layer: * @image_ID: The image. @@ -2093,6 +2018,81 @@ gimp_image_set_unit (gint32 image_ID, return success; } +/** + * gimp_image_get_tattoo_state: + * @image_ID: The image. + * + * Returns the tattoo state associated with the image. + * + * This procedure returns the tattoo state of the image. Use only by + * save/load plugins that wish to preserve an images tattoo state. + * Using this function at other times will produce unexpected results. + * + * Returns: The tattoo_state. + */ +gint +gimp_image_get_tattoo_state (gint32 image_ID) +{ + GimpParam *return_vals; + gint nreturn_vals; + gint tattoo_state = 0; + + return_vals = gimp_run_procedure ("gimp_image_get_tattoo_state", + &nreturn_vals, + GIMP_PDB_IMAGE, image_ID, + GIMP_PDB_END); + + if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS) + tattoo_state = return_vals[1].data.d_int32; + + gimp_destroy_params (return_vals, nreturn_vals); + + return tattoo_state; +} + +/** + * gimp_image_set_tattoo_state: + * @image_ID: The image. + * @tattoo_state: The new image tattoo_state. + * + * Set the tattoo state associated with the image. + * + * This procedure sets the tattoo state of the image. Use only by + * save/load plugins that wish to preserve an images tattoo state. + * Using this function at other times will produce unexpected results. + * A full check of uniqueness of states in layers, channels and paths + * will be performed by this procedure and a execution failure will be + * returned if this fails. A failure will also be returned if the new + * tattoo state value is less than the maximum tattoo value from all of + * the tattoos from the paths, layers and channels. After the image + * data has been loaded and all the tattoos have been set then this is + * the last procedure that should be called. If effectively does a + * status check on the tattoo values that have been set to make sure + * that all is OK. + * + * Returns: TRUE on success. + */ +gboolean +gimp_image_set_tattoo_state (gint32 image_ID, + gint tattoo_state) +{ + GimpParam *return_vals; + gint nreturn_vals; + gboolean success = TRUE; + + return_vals = gimp_run_procedure ("gimp_image_set_tattoo_state", + &nreturn_vals, + GIMP_PDB_IMAGE, image_ID, + GIMP_PDB_INT32, tattoo_state, + GIMP_PDB_END); + + success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS; + + gimp_destroy_params (return_vals, nreturn_vals); + + return success; +} + /** * gimp_image_get_layer_by_tattoo: * @image_ID: The image. diff --git a/libgimp/gimpimage_pdb.h b/libgimp/gimpimage_pdb.h index 6fa581a67c..651deb65f9 100644 --- a/libgimp/gimpimage_pdb.h +++ b/libgimp/gimpimage_pdb.h @@ -33,8 +33,12 @@ gint* gimp_image_list (gint *num gint32 gimp_image_new (gint width, gint height, GimpImageBaseType type); +gint32 gimp_image_duplicate (gint32 image_ID); gboolean gimp_image_delete (gint32 image_ID); GimpImageBaseType gimp_image_base_type (gint32 image_ID); +gint gimp_image_width (gint32 image_ID); +gint gimp_image_height (gint32 image_ID); +gboolean gimp_image_free_shadow (gint32 image_ID); gboolean gimp_image_resize (gint32 image_ID, gint new_width, gint new_height, @@ -50,16 +54,22 @@ gboolean gimp_image_crop (gint32 ima gint offy); gboolean gimp_image_flip (gint32 image_ID, GimpOrientationType flip_type); -gboolean gimp_image_free_shadow (gint32 image_ID); gint* gimp_image_get_layers (gint32 image_ID, gint *num_layers); gint* gimp_image_get_channels (gint32 image_ID, gint *num_channels); gint32 gimp_image_active_drawable (gint32 image_ID); gboolean gimp_image_unset_active_channel (gint32 image_ID); +gint32 gimp_image_get_floating_sel (gint32 image_ID); +gint32 gimp_image_floating_sel_attached_to (gint32 image_ID); gint32 gimp_image_pick_correlate_layer (gint32 image_ID, gint x, gint y); +gboolean gimp_image_add_layer (gint32 image_ID, + gint32 layer_ID, + gint position); +gboolean gimp_image_remove_layer (gint32 image_ID, + gint32 layer_ID); gboolean gimp_image_raise_layer (gint32 image_ID, gint32 layer_ID); gboolean gimp_image_lower_layer (gint32 image_ID, @@ -68,32 +78,27 @@ gboolean gimp_image_raise_layer_to_top (gint32 ima gint32 layer_ID); gboolean gimp_image_lower_layer_to_bottom (gint32 image_ID, gint32 layer_ID); +gboolean gimp_image_add_channel (gint32 image_ID, + gint32 channel_ID, + gint position); +gboolean gimp_image_remove_channel (gint32 image_ID, + gint32 channel_ID); +gboolean gimp_image_raise_channel (gint32 image_ID, + gint32 channel_ID); +gboolean gimp_image_lower_channel (gint32 image_ID, + gint32 layer_ID); +gint32 gimp_image_flatten (gint32 image_ID); gint32 gimp_image_merge_visible_layers (gint32 image_ID, GimpMergeType merge_type); gint32 gimp_image_merge_down (gint32 image_ID, gint32 merge_layer_ID, GimpMergeType merge_type); -gint32 gimp_image_flatten (gint32 image_ID); -gboolean gimp_image_add_layer (gint32 image_ID, - gint32 layer_ID, - gint position); -gboolean gimp_image_remove_layer (gint32 image_ID, - gint32 layer_ID); gboolean gimp_image_add_layer_mask (gint32 image_ID, gint32 layer_ID, gint32 mask_ID); gboolean gimp_image_remove_layer_mask (gint32 image_ID, gint32 layer_ID, GimpMaskApplyMode mode); -gboolean gimp_image_raise_channel (gint32 image_ID, - gint32 channel_ID); -gboolean gimp_image_lower_channel (gint32 image_ID, - gint32 layer_ID); -gboolean gimp_image_add_channel (gint32 image_ID, - gint32 channel_ID, - gint position); -gboolean gimp_image_remove_channel (gint32 image_ID, - gint32 channel_ID); guint8* _gimp_image_get_cmap (gint32 image_ID, gint *num_bytes); gboolean _gimp_image_set_cmap (gint32 image_ID, @@ -101,8 +106,6 @@ gboolean _gimp_image_set_cmap (gint32 ima const guint8 *cmap); gboolean gimp_image_clean_all (gint32 image_ID); gboolean gimp_image_is_dirty (gint32 image_ID); -gint32 gimp_image_get_floating_sel (gint32 image_ID); -gint32 gimp_image_floating_sel_attached_to (gint32 image_ID); gboolean _gimp_image_thumbnail (gint32 image_ID, gint width, gint height, @@ -111,12 +114,6 @@ gboolean _gimp_image_thumbnail (gint32 ima gint *bpp, gint *thumbnail_data_count, guint8 **thumbnail_data); -gboolean gimp_image_set_tattoo_state (gint32 image_ID, - gint tattoo); -gint gimp_image_get_tattoo_state (gint32 image_ID); -gint32 gimp_image_duplicate (gint32 image_ID); -gint gimp_image_width (gint32 image_ID); -gint gimp_image_height (gint32 image_ID); gint32 gimp_image_get_active_layer (gint32 image_ID); gboolean gimp_image_set_active_layer (gint32 image_ID, gint32 active_layer_ID); @@ -147,6 +144,9 @@ gboolean gimp_image_set_resolution (gint32 ima GimpUnit gimp_image_get_unit (gint32 image_ID); gboolean gimp_image_set_unit (gint32 image_ID, GimpUnit unit); +gint gimp_image_get_tattoo_state (gint32 image_ID); +gboolean gimp_image_set_tattoo_state (gint32 image_ID, + gint tattoo_state); gint32 gimp_image_get_layer_by_tattoo (gint32 image_ID, gint tattoo); gint32 gimp_image_get_channel_by_tattoo (gint32 image_ID, diff --git a/libgimp/gimplayer_pdb.c b/libgimp/gimplayer_pdb.c index 0c7f1cbe53..2103232be6 100644 --- a/libgimp/gimplayer_pdb.c +++ b/libgimp/gimplayer_pdb.c @@ -78,6 +78,43 @@ _gimp_layer_new (gint32 image_ID, return layer_ID; } +/** + * gimp_layer_new_from_drawable: + * @drawable_ID: The source drawable from where the new layer is copied. + * @dest_image_ID: The destination image to which to add the layer. + * + * Create a new layer by copying an existing drawable. + * + * This procedure creates a new layer as a copy of the specified + * drawable. The new layer still needs to be added to the image, as + * this is not automatic. Add the new layer with the + * 'gimp_image_add_layer' command. Other attributes such as layer mask + * modes, and offsets should be set with explicit procedure calls. + * + * Returns: The newly copied layer. + */ +gint32 +gimp_layer_new_from_drawable (gint32 drawable_ID, + gint32 dest_image_ID) +{ + GimpParam *return_vals; + gint nreturn_vals; + gint32 layer_copy_ID = -1; + + return_vals = gimp_run_procedure ("gimp_layer_new_from_drawable", + &nreturn_vals, + GIMP_PDB_DRAWABLE, drawable_ID, + GIMP_PDB_IMAGE, dest_image_ID, + GIMP_PDB_END); + + if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS) + layer_copy_ID = return_vals[1].data.d_layer; + + gimp_destroy_params (return_vals, nreturn_vals); + + return layer_copy_ID; +} + /** * _gimp_layer_copy: * @layer_ID: The layer to copy. @@ -117,45 +154,37 @@ _gimp_layer_copy (gint32 layer_ID, } /** - * gimp_layer_create_mask: - * @layer_ID: The layer to which to add the mask. - * @mask_type: The type of mask. + * gimp_layer_add_alpha: + * @layer_ID: The layer. * - * Create a layer mask for the specified specified layer. + * Add an alpha channel to the layer if it doesn't already have one. * - * This procedure creates a layer mask for the specified layer. Layer - * masks serve as an additional alpha channel for a layer. A number of - * ifferent types of masks are allowed for initialisation: completely - * white masks (which will leave the layer fully visible), completely - * black masks (which will give the layer complete transparency, the - * layer's already existing alpha channel (which will leave the layer - * fully visible, but which may be more useful than a white mask), the - * current selection or a grayscale copy of the layer. The layer mask - * still needs to be added to the layer. This can be done with a call - * to 'gimp_image_add_layer_mask'. + * This procedure adds an additional component to the specified layer + * if it does not already possess an alpha channel. An alpha channel + * makes it possible to move a layer from the bottom of the layer stack + * and to clear and erase to transparency, instead of the background + * color. This transforms images of type RGB to RGBA, GRAY to GRAYA, + * and INDEXED to INDEXEDA. * - * Returns: The newly created mask. + * Returns: TRUE on success. */ -gint32 -gimp_layer_create_mask (gint32 layer_ID, - GimpAddMaskType mask_type) +gboolean +gimp_layer_add_alpha (gint32 layer_ID) { GimpParam *return_vals; gint nreturn_vals; - gint32 mask_ID = -1; + gboolean success = TRUE; - return_vals = gimp_run_procedure ("gimp_layer_create_mask", + return_vals = gimp_run_procedure ("gimp_layer_add_alpha", &nreturn_vals, GIMP_PDB_LAYER, layer_ID, - GIMP_PDB_INT32, mask_type, GIMP_PDB_END); - if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS) - mask_ID = return_vals[1].data.d_layer_mask; + success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS; gimp_destroy_params (return_vals, nreturn_vals); - return mask_ID; + return success; } /** @@ -314,40 +343,6 @@ gimp_layer_translate (gint32 layer_ID, return success; } -/** - * gimp_layer_add_alpha: - * @layer_ID: The layer. - * - * Add an alpha channel to the layer if it doesn't already have one. - * - * This procedure adds an additional component to the specified layer - * if it does not already possess an alpha channel. An alpha channel - * makes it possible to move a layer from the bottom of the layer stack - * and to clear and erase to transparency, instead of the background - * color. This transforms images of type RGB to RGBA, GRAY to GRAYA, - * and INDEXED to INDEXEDA. - * - * Returns: TRUE on success. - */ -gboolean -gimp_layer_add_alpha (gint32 layer_ID) -{ - GimpParam *return_vals; - gint nreturn_vals; - gboolean success = TRUE; - - return_vals = gimp_run_procedure ("gimp_layer_add_alpha", - &nreturn_vals, - GIMP_PDB_LAYER, layer_ID, - GIMP_PDB_END); - - success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS; - - gimp_destroy_params (return_vals, nreturn_vals); - - return success; -} - /** * gimp_layer_set_offsets: * @layer_ID: The layer. @@ -385,6 +380,48 @@ gimp_layer_set_offsets (gint32 layer_ID, return success; } +/** + * gimp_layer_create_mask: + * @layer_ID: The layer to which to add the mask. + * @mask_type: The type of mask. + * + * Create a layer mask for the specified specified layer. + * + * This procedure creates a layer mask for the specified layer. Layer + * masks serve as an additional alpha channel for a layer. A number of + * ifferent types of masks are allowed for initialisation: completely + * white masks (which will leave the layer fully visible), completely + * black masks (which will give the layer complete transparency, the + * layer's already existing alpha channel (which will leave the layer + * fully visible, but which may be more useful than a white mask), the + * current selection or a grayscale copy of the layer. The layer mask + * still needs to be added to the layer. This can be done with a call + * to 'gimp_image_add_layer_mask'. + * + * Returns: The newly created mask. + */ +gint32 +gimp_layer_create_mask (gint32 layer_ID, + GimpAddMaskType mask_type) +{ + GimpParam *return_vals; + gint nreturn_vals; + gint32 mask_ID = -1; + + return_vals = gimp_run_procedure ("gimp_layer_create_mask", + &nreturn_vals, + GIMP_PDB_LAYER, layer_ID, + GIMP_PDB_INT32, mask_type, + GIMP_PDB_END); + + if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS) + mask_ID = return_vals[1].data.d_layer_mask; + + gimp_destroy_params (return_vals, nreturn_vals); + + return mask_ID; +} + /** * gimp_layer_get_mask: * @layer_ID: The layer. @@ -448,43 +485,6 @@ gimp_layer_is_floating_sel (gint32 layer_ID) return is_floating_sel; } -/** - * gimp_layer_new_from_drawable: - * @drawable_ID: The source drawable from where the new layer is copied. - * @dest_image_ID: The destination image to which to add the layer. - * - * Create a new layer by copying an existing drawable. - * - * This procedure creates a new layer as a copy of the specified - * drawable. The new layer still needs to be added to the image, as - * this is not automatic. Add the new layer with the - * 'gimp_image_add_layer' command. Other attributes such as layer mask - * modes, and offsets should be set with explicit procedure calls. - * - * Returns: The newly copied layer. - */ -gint32 -gimp_layer_new_from_drawable (gint32 drawable_ID, - gint32 dest_image_ID) -{ - GimpParam *return_vals; - gint nreturn_vals; - gint32 layer_copy_ID = -1; - - return_vals = gimp_run_procedure ("gimp_layer_new_from_drawable", - &nreturn_vals, - GIMP_PDB_DRAWABLE, drawable_ID, - GIMP_PDB_IMAGE, dest_image_ID, - GIMP_PDB_END); - - if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS) - layer_copy_ID = return_vals[1].data.d_layer; - - gimp_destroy_params (return_vals, nreturn_vals); - - return layer_copy_ID; -} - /** * gimp_layer_get_preserve_trans: * @layer_ID: The layer. diff --git a/libgimp/gimplayer_pdb.h b/libgimp/gimplayer_pdb.h index d0ba917637..705c08b7a9 100644 --- a/libgimp/gimplayer_pdb.h +++ b/libgimp/gimplayer_pdb.h @@ -36,10 +36,11 @@ gint32 _gimp_layer_new (gint32 imag const gchar *name, gdouble opacity, GimpLayerModeEffects mode); +gint32 gimp_layer_new_from_drawable (gint32 drawable_ID, + gint32 dest_image_ID); gint32 _gimp_layer_copy (gint32 layer_ID, gboolean add_alpha); -gint32 gimp_layer_create_mask (gint32 layer_ID, - GimpAddMaskType mask_type); +gboolean gimp_layer_add_alpha (gint32 layer_ID); gboolean gimp_layer_scale (gint32 layer_ID, gint new_width, gint new_height, @@ -53,14 +54,13 @@ gboolean gimp_layer_resize_to_image_size (gint32 laye gboolean gimp_layer_translate (gint32 layer_ID, gint offx, gint offy); -gboolean gimp_layer_add_alpha (gint32 layer_ID); gboolean gimp_layer_set_offsets (gint32 layer_ID, gint offx, gint offy); +gint32 gimp_layer_create_mask (gint32 layer_ID, + GimpAddMaskType mask_type); gint32 gimp_layer_get_mask (gint32 layer_ID); gboolean gimp_layer_is_floating_sel (gint32 layer_ID); -gint32 gimp_layer_new_from_drawable (gint32 drawable_ID, - gint32 dest_image_ID); gboolean gimp_layer_get_preserve_trans (gint32 layer_ID); gboolean gimp_layer_set_preserve_trans (gint32 layer_ID, gboolean preserve_trans); diff --git a/libgimp/gimpmisctools_pdb.c b/libgimp/gimpmisctools_pdb.c index 15f28bcca4..006c16485a 100644 --- a/libgimp/gimpmisctools_pdb.c +++ b/libgimp/gimpmisctools_pdb.c @@ -126,7 +126,7 @@ gimp_blend (gint32 drawable_ID, * unused. If the sample_merged parameter is non-zero, the data of the * composite image will be used instead of that for the specified * drawable. This is equivalent to sampling for colors after merging - * all visible layers. In the case of merged sampling, the x,y + * all visible layers. In the case of merged sampling, the x and y * coordinates are relative to the image's origin; otherwise, they are * relative to the drawable's origin. * @@ -188,7 +188,8 @@ gimp_bucket_fill (gint32 drawable_ID, * parameter is non-zero, the data of the composite image will be used * instead of that for the specified drawable. This is equivalent to * sampling for colors after merging all visible layers. In the case of - * a merged sampling, the supplied drawable is ignored. + * a merged sampling, the supplied drawable is ignored except for + * finding the image it belongs to. * * Returns: TRUE on success. */ diff --git a/tools/pdbgen/pdb/drawable.pdb b/tools/pdbgen/pdb/drawable.pdb index 7f2ae12de6..0394085a33 100644 --- a/tools/pdbgen/pdb/drawable.pdb +++ b/tools/pdbgen/pdb/drawable.pdb @@ -697,19 +697,20 @@ CODE "core/gimpdrawable-offset.h" "base/tile.h" "base/tile-manager.h" "base/temp-buf.h" "gimp-intl.h"); -@procs = qw(drawable_merge_shadow drawable_fill drawable_update - drawable_mask_bounds - drawable_get_image drawable_set_image - drawable_has_alpha drawable_type drawable_type_with_alpha +@procs = qw(drawable_delete + drawable_is_layer drawable_is_layer_mask drawable_is_channel + drawable_type drawable_type_with_alpha drawable_has_alpha drawable_is_rgb drawable_is_gray drawable_is_indexed drawable_bpp drawable_width drawable_height drawable_offsets - drawable_is_layer drawable_is_layer_mask drawable_is_channel + drawable_get_image drawable_set_image drawable_get_name drawable_set_name drawable_get_visible drawable_set_visible drawable_get_linked drawable_set_linked drawable_get_tattoo drawable_set_tattoo + drawable_mask_bounds drawable_merge_shadow drawable_update drawable_get_pixel drawable_set_pixel - drawable_thumbnail drawable_offset drawable_delete); + drawable_fill drawable_offset + drawable_thumbnail); %exports = (app => [@procs], lib => [@procs]); $desc = 'Drawable procedures'; diff --git a/tools/pdbgen/pdb/image.pdb b/tools/pdbgen/pdb/image.pdb index 202e2f70d4..390e3eaa66 100644 --- a/tools/pdbgen/pdb/image.pdb +++ b/tools/pdbgen/pdb/image.pdb @@ -31,7 +31,8 @@ sub channel_arg () {{ sub new_dim_args { foreach (qw(width height)) { - push @inargs, { name => "new_$_", type => '0 < int32', + push @inargs, { name => "new_$_", + type => '0 < int32', desc => "New image $_: %%desc%%" } } } @@ -42,11 +43,11 @@ sub image_list_proc { $blurb = "Returns the list of ${type}s contained in the specified image."; $help = < 'image', type => 'image', init => 1, + { name => 'image', type => 'image', init => 1, desc => 'The ID of the newly created image' } ); @@ -270,6 +271,57 @@ CODE ); } +sub image_duplicate { + $blurb = 'Duplicate the specified image'; + + $help = <<'HELP'; +This procedure duplicates the specified image, copying all layers, channels, +and image information. +HELP + + &std_pdb_misc; + $date = '1997'; + + @inargs = ( &std_image_arg ); + + @outargs = ( + { name => 'new_image', type => 'image', + desc => 'The new, duplicated image', init => 1 } + ); + + %invoke = ( + headers => [ qw("core/gimpimage-duplicate.h") ], + code => <<'CODE' +success = (new_image = gimp_image_duplicate (gimage)) != NULL; +CODE + ); +} + +sub image_delete { + $blurb = 'Delete the specified image.'; + + $help = <<'HELP'; +If there are no displays associated with this image it will be deleted. +This means that you can not delete an image through the PDB that was +created by the user. If the associated display was however created +through the PDB and you know the display ID, you may delete the display. +Removal of the last associated display will then delete the image. +HELP + + &std_pdb_misc; + + @inargs = ( &std_image_arg ); + + %invoke = ( code => <<'CODE' ); +{ + if (gimage->disp_count == 0) + g_object_unref (gimage); + else + success = FALSE; +} +CODE +} + sub image_resize { $blurb = 'Resize the image to the specified extents.'; @@ -340,7 +392,7 @@ sub image_crop { $help = <<'HELP'; This procedure crops the image so that it's new width and height are equal to the supplied parameters. Offsets are also provided which describe the position -of the previous image's content. All channels and layers within the image are +of the previous image's content. All channels and layers within the image are cropped to the new image extents; this includes the image selection mask. If any parameters are out of range, an error is returned. HELP @@ -401,31 +453,6 @@ CODE ); } -sub image_delete { - $blurb = 'Delete the specified image.'; - - $help = <<'HELP'; -If there are no displays associated with this image it will be deleted. -This means that you can not delete an image through the PDB that was -created by the user. If the associated display was however created -through the PDB and you know the display ID, you may delete the display. -Removal of the last associated display will then delete the image. -HELP - - &std_pdb_misc; - - @inargs = ( &std_image_arg ); - - %invoke = ( code => <<'CODE' ); -{ - if (gimage->disp_count == 0) - g_object_unref (gimage); - else - success = FALSE; -} -CODE -} - sub image_free_shadow { $blurb = "Free the specified image's shadow data (if it exists)."; @@ -581,7 +608,7 @@ HELP &std_image_arg, { name => 'merge_layer', type => 'layer', desc => 'The layer to merge down from' }, - { name => 'merge_type', + { name => 'merge_type', type => 'enum GimpMergeType (no GIMP_FLATTEN_IMAGE)', desc => 'The type of merge: { %%desc%% }' } ); @@ -988,7 +1015,6 @@ CODE } foreach (qw(width height)) { - push @procs, "image_$_"; eval < GIMP_MAX_RESOLUTION || - !FINITE (yresolution) || + ! FINITE (yresolution) || yresolution < GIMP_MIN_RESOLUTION || yresolution > GIMP_MAX_RESOLUTION) { - g_message (_("Image resolution is out of bounds, " + g_message (_("Image resolution is out of bounds, " "using the default resolution instead.")); success = FALSE; } else { - gimage->xresolution = xresolution; - gimage->yresolution = yresolution; + gimp_image_set_resolution (gimage, xresolution, yresolution); } } CODE CODE2 + my $unit_help = <<'HELP'; This value is independent of any of the layers in this image. See the gimp_unit_* procedure definitions for the valid range of unit IDs and a @@ -1236,7 +1262,8 @@ my $unit_misc = <<'CODE'; $author = $copyright = 'Michael Natterer'; $date = '1998'; CODE -&image_accessors('unit', 'unit (min GIMP_UNIT_INCH)', 'unit', 0, + +&image_accessors('unit', 'unit (min GIMP_UNIT_INCH)', 'unit', 1, [ < $_, type => 'int32', desc => "The previews $_", init => 1 }; + push @args, { name => $_, + type => 'int32', + desc => "The previews $_", + init => 1 }; } @args; } @@ -1293,7 +1356,7 @@ sub image_thumbnail { $blurb = 'Get a thumbnail of an image.'; $help = <<'HELP'; -This function gets data from which a thumbnail of an image preview can be +This function gets data from which a thumbnail of an image preview can be created. Maximum x or y dimension is 1024 pixels. The pixels are returned in the RGB[A] format. The bpp return value gives the number of bits per pixel in the image. If the image has an alpha channel, it is also returned. @@ -1304,14 +1367,10 @@ HELP @inargs = ( &std_image_arg, - { name => 'width', - type => '0 < int32 <= 1024', - desc => 'The thumbnail width', - alias => 'req_width' }, - { name => 'height', - type => '0 < int32 <= 1024', - desc => 'The thumbnail height', - alias => 'req_height' } + { name => 'width', type => '0 < int32 <= 1024', + desc => 'The thumbnail width', alias => 'req_width' }, + { name => 'height', type => '0 < int32 <= 1024', + desc => 'The thumbnail height', alias => 'req_height' } ); @outargs = ( @@ -1349,7 +1408,7 @@ HELP { num_bytes = buf->height * buf->width * buf->bytes; thumbnail_data = g_memdup (temp_buf_data (buf), num_bytes); - width = buf->width; + width = buf->width; height = buf->height; bpp = buf->bytes; @@ -1360,94 +1419,6 @@ CODE ); } -sub image_get_tattoo_state { - $blurb = 'Returns the tattoo state associated with the image.'; - - $help = <<'HELP'; -This procedure returns the tattoo state of the image. Use only by -save/load plugins that wish to preserve an images tattoo state. Using this -function at other times will produce unexpected results. -HELP - - $author = $copyright = 'Andy Thomas'; - $date = '2000'; - - @inargs = ( &std_image_arg ); - - @outargs = ( - { name => 'tattoo', type => 'int32', - desc => 'The tattoo state associated with the image', init => 1 } - ); - - %invoke = ( - code => <<'CODE' -{ - tattoo = gimp_image_get_tattoo_state (gimage); -} -CODE - ); -} - -sub image_set_tattoo_state { - $blurb = 'Set the tattoo state associated with the image.'; - - $help = <<'HELP'; -This procedure sets the tattoo state of the image. Use only by -save/load plugins that wish to preserve an images tattoo state. Using this -function at other times will produce unexpected results. A full check of -uniqueness of states in layers, channels and paths will be performed by this -procedure and a execution failure will be returned if this fails. A failure -will also be returned if the new tattoo state value is less than the maximum -tattoo value from all of the tattoos from the paths,layers and channels. After -the image data has been loaded and all the tattoos have been set then this is -the last procedure that should be called. If effectively does a status check -on the tattoo values that have been set to make sure that all is OK. -HELP - - $author = $copyright = 'Andy Thomas'; - $date = '2000'; - - @inargs = ( - &std_image_arg, - { name => 'tattoo', type => 'int32', - desc => 'The new tattoo state of the image' } - ); - - %invoke = ( - code => <<'CODE' -{ - success = gimp_image_set_tattoo_state (gimage, tattoo); -} -CODE - ); -} - -sub image_duplicate { - $blurb = 'Duplicate the specified image'; - - $help = <<'HELP'; -This procedure duplicates the specified image, copying all layers, channels, -and image information. -HELP - - &std_pdb_misc; - $date = '1997'; - - @inargs = ( &std_image_arg ); - - @outargs = ( - { name => 'new_image', type => 'image', - desc => 'The new, duplicated image', init => 1 } - ); - - %invoke = ( - headers => [ qw("core/gimpimage-duplicate.h") ], - code => <<'CODE' -success = (new_image = gimp_image_duplicate (gimage)) != NULL; -CODE - ); -} - @headers = qw( "core/gimp.h" "core/gimpcontainer.h" @@ -1480,26 +1451,26 @@ gimlist_cb (gpointer im, } CODE -unshift @procs, qw(image_list image_new image_delete image_base_type - image_resize image_scale image_crop image_flip +unshift @procs, qw(image_list image_new image_duplicate image_delete + image_base_type + image_width image_height image_free_shadow + image_resize image_scale image_crop image_flip image_get_layers image_get_channels - image_active_drawable image_unset_active_channel + image_active_drawable + image_unset_active_channel + image_get_floating_sel image_floating_sel_attached_to image_pick_correlate_layer - image_raise_layer image_lower_layer image_raise_layer_to_top - image_lower_layer_to_bottom - image_merge_visible_layers image_merge_down - image_flatten image_add_layer image_remove_layer - image_add_layer_mask image_remove_layer_mask - image_raise_channel image_lower_channel + image_raise_layer image_lower_layer + image_raise_layer_to_top image_lower_layer_to_bottom image_add_channel image_remove_channel + image_raise_channel image_lower_channel + image_flatten image_merge_visible_layers image_merge_down + image_add_layer_mask image_remove_layer_mask image_get_cmap image_set_cmap image_clean_all image_is_dirty - image_get_floating_sel image_floating_sel_attached_to - image_thumbnail - image_set_tattoo_state image_get_tattoo_state - image_duplicate); + image_thumbnail); %exports = (app => [@procs], lib => [@procs]); $desc = 'Image'; diff --git a/tools/pdbgen/pdb/layer.pdb b/tools/pdbgen/pdb/layer.pdb index a2e43050db..68b7489329 100644 --- a/tools/pdbgen/pdb/layer.pdb +++ b/tools/pdbgen/pdb/layer.pdb @@ -592,11 +592,12 @@ CODE2 @headers = qw("config/gimpcoreconfig.h" "core/gimp.h" "core/gimpimage-undo.h" "core/gimpitem-linked.h" "pdb_glue.h" "gimp-intl.h"); -unshift @procs, qw(layer_new layer_copy layer_create_mask layer_scale - layer_resize layer_resize_to_image_size - layer_translate layer_add_alpha layer_set_offsets - layer_get_mask - layer_is_floating_sel layer_new_from_drawable); +unshift @procs, qw(layer_new layer_new_from_drawable layer_copy + layer_add_alpha + layer_scale layer_resize layer_resize_to_image_size + layer_translate layer_set_offsets + layer_create_mask layer_get_mask + layer_is_floating_sel); %exports = (app => [@procs], lib => [@procs]); $desc = 'Layer'; diff --git a/tools/pdbgen/pdb/misc_tools.pdb b/tools/pdbgen/pdb/misc_tools.pdb index c0f06e7bd7..5e997bd8d0 100644 --- a/tools/pdbgen/pdb/misc_tools.pdb +++ b/tools/pdbgen/pdb/misc_tools.pdb @@ -27,26 +27,12 @@ sub drawable_arg () {{ desc => 'The affected drawable', }} -sub drawable_out_arg { - my $type = shift; - my $arg = &drawable_arg; - $arg->{desc} = "The $type drawable"; - $arg->{no_declare} = 1; - $arg; -} - sub sample_merged_arg () {{ name => 'sample_merged', type => 'boolean', desc => 'Use the composite image, not the drawable' }} -sub threshold_arg () {{ - name => 'threshold', - type => '0 <= int32 <= 255', - desc => 'Threshold in intensity levels %%desc%%' -}} - # The defs @@ -135,16 +121,18 @@ a seed fill starting at the specified coordinates. BLURB $help = <<'HELP'; -This tool requires information on the paint application mode, and the fill -mode, which can either be in the foreground color, or in the currently active -pattern. If there is no selection, a seed fill is executed at the specified -coordinates and extends outward in keeping with the threshold parameter. If -there is a selection in the target image, the threshold, sample merged, x, and -y arguments are unused. If the sample_merged parameter is non-zero, the data of -the composite image will be used instead of that for the specified drawable. -This is equivalent to sampling for colors after merging all visible layers. In -the case of merged sampling, the x,y coordinates are relative to the image's -origin; otherwise, they are relative to the drawable's origin. +This tool requires information on the paint application mode, and the +fill mode, which can either be in the foreground color, or in the +currently active pattern. If there is no selection, a seed fill is +executed at the specified coordinates and extends outward in keeping +with the threshold parameter. If there is a selection in the target +image, the threshold, sample merged, x, and y arguments are unused. If +the sample_merged parameter is non-zero, the data of the composite +image will be used instead of that for the specified drawable. This +is equivalent to sampling for colors after merging all visible +layers. In the case of merged sampling, the x and y coordinates are +relative to the image's origin; otherwise, they are relative to the +drawable's origin. HELP &std_pdb_misc; @@ -164,7 +152,7 @@ HELP desc => "The threshold determines how extensive the seed fill will be. It's value is specified in terms of intensity levels (%%desc%%). $validity" }, - &sample_merged_arg, + &sample_merged_arg ); foreach (qw(x y)) { @@ -208,16 +196,18 @@ Determine the color at the given drawable coordinates BLURB $help = <<'HELP'; -This tool determines the color at the specified coordinates. The returned color -is an RGB triplet even for grayscale and indexed drawables. If the coordinates -lie outside of the extents of the specified drawable, then an error is -returned. If the drawable has an alpha channel, the algorithm examines the -alpha value of the drawable at the coordinates. If the alpha value is -completely transparent (0), then an error is returned. If the sample_merged -parameter is non-zero, the data of the composite image will be used instead of -that for the specified drawable. This is equivalent to sampling for colors -after merging all visible layers. In the case of a merged sampling, the -supplied drawable is ignored. +This tool determines the color at the specified coordinates. The +returned color is an RGB triplet even for grayscale and indexed +drawables. If the coordinates lie outside of the extents of the +specified drawable, then an error is returned. If the drawable has an +alpha channel, the algorithm examines the alpha value of the drawable +at the coordinates. If the alpha value is completely transparent (0), +then an error is returned. If the sample_merged parameter is non-zero, +the data of the composite image will be used instead of that for the +specified drawable. This is equivalent to sampling for colors after +merging all visible layers. In the case of a merged sampling, the +supplied drawable is ignored except for finding the image it belongs +to. HELP &std_pdb_misc;