diff --git a/ChangeLog b/ChangeLog index 274a01669c..c04f36e751 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,18 @@ +2004-11-02 Michael Natterer + + * tools/pdbgen/pdb/drawable_transform.pdb: added _defaults() + variants (flip_defaults, rotate_defaults, ...) for all transform + functions which finally call gimp_drawable_transform_affine(). + The _defaults() functions don't take the whole interpolation_type, + supersample etc. parameter overkill, but only a "interpolation" + boolean like the old PDB wrappers. + + * libgimp/gimp.def: changed accordingly. + + * app/pdb/drawable_transform_cmds.c + * app/pdb/internal_procs.c + * libgimp/gimpdrawabletransform_pdb.[ch]: regenerated. + 2004-11-02 Michael Natterer * tools/pdbgen/pdb/drawable_transform.pdb: renamed flip() and diff --git a/app/pdb/drawable_transform_cmds.c b/app/pdb/drawable_transform_cmds.c index 88e3f78771..e113b11deb 100644 --- a/app/pdb/drawable_transform_cmds.c +++ b/app/pdb/drawable_transform_cmds.c @@ -39,26 +39,40 @@ static ProcRecord drawable_transform_flip_simple_proc; static ProcRecord drawable_transform_flip_proc; +static ProcRecord drawable_transform_flip_defaults_proc; static ProcRecord drawable_transform_perspective_proc; +static ProcRecord drawable_transform_perspective_defaults_proc; static ProcRecord drawable_transform_rotate_simple_proc; static ProcRecord drawable_transform_rotate_proc; +static ProcRecord drawable_transform_rotate_defaults_proc; static ProcRecord drawable_transform_scale_proc; +static ProcRecord drawable_transform_scale_defaults_proc; static ProcRecord drawable_transform_shear_proc; +static ProcRecord drawable_transform_shear_defaults_proc; static ProcRecord drawable_transform_2d_proc; +static ProcRecord drawable_transform_2d_defaults_proc; static ProcRecord drawable_transform_matrix_proc; +static ProcRecord drawable_transform_matrix_defaults_proc; void register_drawable_transform_procs (Gimp *gimp) { procedural_db_register (gimp, &drawable_transform_flip_simple_proc); procedural_db_register (gimp, &drawable_transform_flip_proc); + procedural_db_register (gimp, &drawable_transform_flip_defaults_proc); procedural_db_register (gimp, &drawable_transform_perspective_proc); + procedural_db_register (gimp, &drawable_transform_perspective_defaults_proc); procedural_db_register (gimp, &drawable_transform_rotate_simple_proc); procedural_db_register (gimp, &drawable_transform_rotate_proc); + procedural_db_register (gimp, &drawable_transform_rotate_defaults_proc); procedural_db_register (gimp, &drawable_transform_scale_proc); + procedural_db_register (gimp, &drawable_transform_scale_defaults_proc); procedural_db_register (gimp, &drawable_transform_shear_proc); + procedural_db_register (gimp, &drawable_transform_shear_defaults_proc); procedural_db_register (gimp, &drawable_transform_2d_proc); + procedural_db_register (gimp, &drawable_transform_2d_defaults_proc); procedural_db_register (gimp, &drawable_transform_matrix_proc); + procedural_db_register (gimp, &drawable_transform_matrix_defaults_proc); } static Argument * @@ -333,6 +347,145 @@ static ProcRecord drawable_transform_flip_proc = { { drawable_transform_flip_invoker } } }; +static Argument * +drawable_transform_flip_defaults_invoker (Gimp *gimp, + GimpContext *context, + GimpProgress *progress, + Argument *args) +{ + gboolean success = TRUE; + Argument *return_args; + GimpDrawable *drawable; + gdouble x0; + gdouble y0; + gdouble x1; + gdouble y1; + gboolean interpolation; + gboolean clip_result; + + drawable = (GimpDrawable *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int); + if (! (GIMP_IS_DRAWABLE (drawable) && ! gimp_item_is_removed (GIMP_ITEM (drawable)))) + success = FALSE; + + x0 = args[1].value.pdb_float; + + y0 = args[2].value.pdb_float; + + x1 = args[3].value.pdb_float; + + y1 = args[4].value.pdb_float; + + interpolation = args[5].value.pdb_int ? TRUE : FALSE; + + clip_result = args[6].value.pdb_int ? TRUE : FALSE; + + if (success) + { + gint x, y, width, height; + + success = gimp_item_is_attached (GIMP_ITEM (drawable)); + + if (success && + gimp_drawable_mask_intersect (drawable, &x, &y, &width, &height)) + { + GimpMatrix3 matrix; + GimpInterpolationType interpolation_type = GIMP_INTERPOLATION_NONE; + + /* Assemble the transformation matrix */ + gimp_transform_matrix_flip_free (x, y, width, height, + x0, y0, x1, y1, + &matrix); + + if (interpolation) + interpolation_type = gimp->config->interpolation_type; + + if (progress) + gimp_progress_start (progress, _("Flip..."), FALSE); + + /* Transform the selection */ + success = gimp_drawable_transform_affine (drawable, context, + &matrix, GIMP_TRANSFORM_FORWARD, + interpolation_type, + interpolation, 3, + clip_result, progress); + if (progress) + gimp_progress_end (progress); + } + } + + return_args = procedural_db_return_args (&drawable_transform_flip_defaults_proc, success); + + if (success) + return_args[1].value.pdb_int = gimp_item_get_ID (GIMP_ITEM (drawable)); + + return return_args; +} + +static ProcArg drawable_transform_flip_defaults_inargs[] = +{ + { + GIMP_PDB_DRAWABLE, + "drawable", + "The affected drawable" + }, + { + GIMP_PDB_FLOAT, + "x0", + "horz. coord. of one end of axis" + }, + { + GIMP_PDB_FLOAT, + "y0", + "vert. coord. of one end of axis" + }, + { + GIMP_PDB_FLOAT, + "x1", + "horz. coord. of other end of axis" + }, + { + GIMP_PDB_FLOAT, + "y1", + "vert. coord. of other end of axis" + }, + { + GIMP_PDB_INT32, + "interpolation", + "Whether to use interpolation and supersampling" + }, + { + GIMP_PDB_INT32, + "clip_result", + "Whether to clip results" + } +}; + +static ProcArg drawable_transform_flip_defaults_outargs[] = +{ + { + GIMP_PDB_DRAWABLE, + "drawable", + "The flipped drawable" + } +}; + +static ProcRecord drawable_transform_flip_defaults_proc = +{ + "gimp_drawable_transform_flip_defaults", + "Flip the specified drawable around a given line.", + "This procedure is a variant of gimp_drawable_transform_flip() which uses no interpolation/supersampling at all, or default values (depending on the 'interpolation' parameter).", + "João S. O. Bueno Calligaris", + "João S. O. Bueno Calligaris", + "2004", + NULL, + GIMP_INTERNAL, + 7, + drawable_transform_flip_defaults_inargs, + 1, + drawable_transform_flip_defaults_outargs, + { { drawable_transform_flip_defaults_invoker } } +}; + static Argument * drawable_transform_perspective_invoker (Gimp *gimp, GimpContext *context, @@ -527,6 +680,174 @@ static ProcRecord drawable_transform_perspective_proc = { { drawable_transform_perspective_invoker } } }; +static Argument * +drawable_transform_perspective_defaults_invoker (Gimp *gimp, + GimpContext *context, + GimpProgress *progress, + Argument *args) +{ + gboolean success = TRUE; + Argument *return_args; + GimpDrawable *drawable; + gboolean interpolation; + gboolean clip_result; + gdouble trans_info[8]; + + drawable = (GimpDrawable *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int); + if (! (GIMP_IS_DRAWABLE (drawable) && ! gimp_item_is_removed (GIMP_ITEM (drawable)))) + success = FALSE; + + trans_info[X0] = args[1].value.pdb_float; + + trans_info[Y0] = args[2].value.pdb_float; + + trans_info[X1] = args[3].value.pdb_float; + + trans_info[Y1] = args[4].value.pdb_float; + + trans_info[X2] = args[5].value.pdb_float; + + trans_info[Y2] = args[6].value.pdb_float; + + trans_info[X3] = args[7].value.pdb_float; + + trans_info[Y3] = args[8].value.pdb_float; + + interpolation = args[9].value.pdb_int ? TRUE : FALSE; + + clip_result = args[10].value.pdb_int ? TRUE : FALSE; + + if (success) + { + gint x, y, width, height; + + success = gimp_item_is_attached (GIMP_ITEM (drawable)); + + if (success && + gimp_drawable_mask_intersect (drawable, &x, &y, &width, &height)) + { + GimpMatrix3 matrix; + GimpInterpolationType interpolation_type = GIMP_INTERPOLATION_NONE; + + /* Assemble the transformation matrix */ + gimp_transform_matrix_perspective (x, y, width, height, + trans_info[X0], trans_info[Y0], + trans_info[X1], trans_info[Y1], + trans_info[X2], trans_info[Y2], + trans_info[X3], trans_info[Y3], + &matrix); + + if (interpolation) + interpolation_type = gimp->config->interpolation_type; + + if (progress) + gimp_progress_start (progress, _("Perspective..."), FALSE); + + /* Perspective the selection */ + success = gimp_drawable_transform_affine (drawable, context, + &matrix, GIMP_TRANSFORM_FORWARD, + interpolation_type, + interpolation, 3, + clip_result, progress); + + if (progress) + gimp_progress_end (progress); + } + } + + return_args = procedural_db_return_args (&drawable_transform_perspective_defaults_proc, success); + + if (success) + return_args[1].value.pdb_int = gimp_item_get_ID (GIMP_ITEM (drawable)); + + return return_args; +} + +static ProcArg drawable_transform_perspective_defaults_inargs[] = +{ + { + GIMP_PDB_DRAWABLE, + "drawable", + "The affected drawable" + }, + { + GIMP_PDB_FLOAT, + "x0", + "The new x coordinate of upper-left corner of original bounding box" + }, + { + GIMP_PDB_FLOAT, + "y0", + "The new y coordinate of upper-left corner of original bounding box" + }, + { + GIMP_PDB_FLOAT, + "x1", + "The new x coordinate of upper-right corner of original bounding box" + }, + { + GIMP_PDB_FLOAT, + "y1", + "The new y coordinate of upper-right corner of original bounding box" + }, + { + GIMP_PDB_FLOAT, + "x2", + "The new x coordinate of lower-left corner of original bounding box" + }, + { + GIMP_PDB_FLOAT, + "y2", + "The new y coordinate of lower-left corner of original bounding box" + }, + { + GIMP_PDB_FLOAT, + "x3", + "The new x coordinate of lower-right corner of original bounding box" + }, + { + GIMP_PDB_FLOAT, + "y3", + "The new y coordinate of lower-right corner of original bounding box" + }, + { + GIMP_PDB_INT32, + "interpolation", + "Whether to use interpolation and supersampling" + }, + { + GIMP_PDB_INT32, + "clip_result", + "Whether to clip results" + } +}; + +static ProcArg drawable_transform_perspective_defaults_outargs[] = +{ + { + GIMP_PDB_DRAWABLE, + "drawable", + "The newly mapped drawable" + } +}; + +static ProcRecord drawable_transform_perspective_defaults_proc = +{ + "gimp_drawable_transform_perspective_defaults", + "Perform a possibly non-affine transformation on the specified drawable, with extra parameters.", + "This procedure is a variant of gimp_drawable_transform_perspective() which uses no interpolation/supersampling at all, or default values (depending on the 'interpolation' parameter).", + "João S. O. Bueno Calligaris", + "João S. O. Bueno Calligaris", + "2004", + NULL, + GIMP_INTERNAL, + 11, + drawable_transform_perspective_defaults_inargs, + 1, + drawable_transform_perspective_defaults_outargs, + { { drawable_transform_perspective_defaults_invoker } } +}; + static Argument * drawable_transform_rotate_simple_invoker (Gimp *gimp, GimpContext *context, @@ -811,6 +1132,149 @@ static ProcRecord drawable_transform_rotate_proc = { { drawable_transform_rotate_invoker } } }; +static Argument * +drawable_transform_rotate_defaults_invoker (Gimp *gimp, + GimpContext *context, + GimpProgress *progress, + Argument *args) +{ + gboolean success = TRUE; + Argument *return_args; + GimpDrawable *drawable; + gdouble angle; + gboolean auto_center; + gint32 center_x; + gint32 center_y; + gboolean interpolation; + gboolean clip_result; + + drawable = (GimpDrawable *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int); + if (! (GIMP_IS_DRAWABLE (drawable) && ! gimp_item_is_removed (GIMP_ITEM (drawable)))) + success = FALSE; + + angle = args[1].value.pdb_float; + + auto_center = args[2].value.pdb_int ? TRUE : FALSE; + + center_x = args[3].value.pdb_int; + + center_y = args[4].value.pdb_int; + + interpolation = args[5].value.pdb_int ? TRUE : FALSE; + + clip_result = args[6].value.pdb_int ? TRUE : FALSE; + + if (success) + { + gint x, y, width, height; + + success = gimp_item_is_attached (GIMP_ITEM (drawable)); + + if (success && + gimp_drawable_mask_intersect (drawable, &x, &y, &width, &height)) + { + GimpMatrix3 matrix; + GimpInterpolationType interpolation_type = GIMP_INTERPOLATION_NONE; + + /* Assemble the transformation matrix */ + if (auto_center) + gimp_transform_matrix_rotate (x, y, width, height, angle, + &matrix); + else + gimp_transform_matrix_rotate_center (center_x, center_y, angle, + &matrix); + + if (interpolation) + interpolation_type = gimp->config->interpolation_type; + + if (progress) + gimp_progress_start (progress, _("Rotating..."), FALSE); + + /* Rotate the selection */ + success = gimp_drawable_transform_affine (drawable, context, + &matrix, GIMP_TRANSFORM_FORWARD, + interpolation_type, + interpolation, 3, + clip_result, progress); + + if (progress) + gimp_progress_end (progress); + } + } + + return_args = procedural_db_return_args (&drawable_transform_rotate_defaults_proc, success); + + if (success) + return_args[1].value.pdb_int = gimp_item_get_ID (GIMP_ITEM (drawable)); + + return return_args; +} + +static ProcArg drawable_transform_rotate_defaults_inargs[] = +{ + { + GIMP_PDB_DRAWABLE, + "drawable", + "The affected drawable" + }, + { + GIMP_PDB_FLOAT, + "angle", + "The angle of rotation (radians)" + }, + { + GIMP_PDB_INT32, + "auto_center", + "Whether to automatically rotate around the selection center" + }, + { + GIMP_PDB_INT32, + "center_x", + "The hor. coordinate of the center of rotation" + }, + { + GIMP_PDB_INT32, + "center_y", + "The vert. coordinate of the center of rotation" + }, + { + GIMP_PDB_INT32, + "interpolation", + "Whether to use interpolation and supersampling" + }, + { + GIMP_PDB_INT32, + "clip_result", + "Whether to clip results" + } +}; + +static ProcArg drawable_transform_rotate_defaults_outargs[] = +{ + { + GIMP_PDB_DRAWABLE, + "drawable", + "The rotated drawable" + } +}; + +static ProcRecord drawable_transform_rotate_defaults_proc = +{ + "gimp_drawable_transform_rotate_defaults", + "Rotate the specified drawable about given coordinates through the specified angle.", + "This procedure is a variant of gimp_drawable_transform_rotate() which uses no interpolation/supersampling at all, or default values (depending on the 'interpolation' parameter).", + "João S. O. Bueno Calligaris", + "João S. O. Bueno Calligaris", + "2004", + NULL, + GIMP_INTERNAL, + 7, + drawable_transform_rotate_defaults_inargs, + 1, + drawable_transform_rotate_defaults_outargs, + { { drawable_transform_rotate_defaults_invoker } } +}; + static Argument * drawable_transform_scale_invoker (Gimp *gimp, GimpContext *context, @@ -979,6 +1443,148 @@ static ProcRecord drawable_transform_scale_proc = { { drawable_transform_scale_invoker } } }; +static Argument * +drawable_transform_scale_defaults_invoker (Gimp *gimp, + GimpContext *context, + GimpProgress *progress, + Argument *args) +{ + gboolean success = TRUE; + Argument *return_args; + GimpDrawable *drawable; + gboolean interpolation; + gboolean clip_result; + gdouble trans_info[4]; + + drawable = (GimpDrawable *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int); + if (! (GIMP_IS_DRAWABLE (drawable) && ! gimp_item_is_removed (GIMP_ITEM (drawable)))) + success = FALSE; + + trans_info[X0] = args[1].value.pdb_float; + + trans_info[Y0] = args[2].value.pdb_float; + + trans_info[X1] = args[3].value.pdb_float; + + trans_info[Y1] = args[4].value.pdb_float; + + interpolation = args[5].value.pdb_int ? TRUE : FALSE; + + clip_result = args[6].value.pdb_int ? TRUE : FALSE; + + if (success) + { + gint x, y, width, height; + + success = (gimp_item_is_attached (GIMP_ITEM (drawable)) && + trans_info[X0] < trans_info[X1] && + trans_info[Y0] < trans_info[X1]); + + if (success && + gimp_drawable_mask_intersect (drawable, &x, &y, &width, &height)) + { + GimpMatrix3 matrix; + GimpInterpolationType interpolation_type = GIMP_INTERPOLATION_NONE; + + /* Assemble the transformation matrix */ + gimp_transform_matrix_scale (x, y, width, height, + trans_info[X0], + trans_info[Y0], + trans_info[X1] - trans_info[X0], + trans_info[Y1] - trans_info[Y0], + &matrix); + + if (interpolation) + interpolation_type = gimp->config->interpolation_type; + + if (progress) + gimp_progress_start (progress, _("Scaling..."), FALSE); + + /* Scale the selection */ + success = gimp_drawable_transform_affine (drawable, context, + &matrix, GIMP_TRANSFORM_FORWARD, + interpolation_type, + interpolation, 3, + clip_result, progress); + + if (progress) + gimp_progress_end (progress); + } + } + + return_args = procedural_db_return_args (&drawable_transform_scale_defaults_proc, success); + + if (success) + return_args[1].value.pdb_int = gimp_item_get_ID (GIMP_ITEM (drawable)); + + return return_args; +} + +static ProcArg drawable_transform_scale_defaults_inargs[] = +{ + { + GIMP_PDB_DRAWABLE, + "drawable", + "The affected drawable" + }, + { + GIMP_PDB_FLOAT, + "x0", + "The new x coordinate of upper-left corner of newly scaled region" + }, + { + GIMP_PDB_FLOAT, + "y0", + "The new y coordinate of upper-left corner of newly scaled region" + }, + { + GIMP_PDB_FLOAT, + "x1", + "The new x coordinate of lower-right corner of newly scaled region" + }, + { + GIMP_PDB_FLOAT, + "y1", + "The new y coordinate of lower-right corner of newly scaled region" + }, + { + GIMP_PDB_INT32, + "interpolation", + "Whether to use interpolation and supersampling" + }, + { + GIMP_PDB_INT32, + "clip_result", + "Whether to clip results" + } +}; + +static ProcArg drawable_transform_scale_defaults_outargs[] = +{ + { + GIMP_PDB_DRAWABLE, + "drawable", + "The scaled drawable" + } +}; + +static ProcRecord drawable_transform_scale_defaults_proc = +{ + "gimp_drawable_transform_scale_defaults", + "Scale the specified drawable with extra parameters", + "This procedure is a variant of gimp_drawable_transform_scale() which uses no interpolation/supersampling at all, or default values (depending on the 'interpolation' parameter).", + "João S. O. Bueno Calligaris", + "João S. O. Bueno Calligaris", + "2004", + NULL, + GIMP_INTERNAL, + 7, + drawable_transform_scale_defaults_inargs, + 1, + drawable_transform_scale_defaults_outargs, + { { drawable_transform_scale_defaults_invoker } } +}; + static Argument * drawable_transform_shear_invoker (Gimp *gimp, GimpContext *context, @@ -1131,6 +1737,132 @@ static ProcRecord drawable_transform_shear_proc = { { drawable_transform_shear_invoker } } }; +static Argument * +drawable_transform_shear_defaults_invoker (Gimp *gimp, + GimpContext *context, + GimpProgress *progress, + Argument *args) +{ + gboolean success = TRUE; + Argument *return_args; + GimpDrawable *drawable; + gint32 shear_type; + gdouble magnitude; + gboolean interpolation; + gboolean clip_result; + + drawable = (GimpDrawable *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int); + if (! (GIMP_IS_DRAWABLE (drawable) && ! gimp_item_is_removed (GIMP_ITEM (drawable)))) + success = FALSE; + + shear_type = args[1].value.pdb_int; + if (shear_type < GIMP_ORIENTATION_HORIZONTAL || shear_type > GIMP_ORIENTATION_VERTICAL) + success = FALSE; + + magnitude = args[2].value.pdb_float; + + interpolation = args[3].value.pdb_int ? TRUE : FALSE; + + clip_result = args[4].value.pdb_int ? TRUE : FALSE; + + if (success) + { + gint x, y, width, height; + + success = gimp_item_is_attached (GIMP_ITEM (drawable)); + + if (success && + gimp_drawable_mask_intersect (drawable, &x, &y, &width, &height)) + { + GimpMatrix3 matrix; + GimpInterpolationType interpolation_type = GIMP_INTERPOLATION_NONE; + + /* Assemble the transformation matrix */ + gimp_transform_matrix_shear (x, y, width, height, + shear_type, magnitude, + &matrix); + + if (interpolation) + interpolation_type = gimp->config->interpolation_type; + + if (progress) + gimp_progress_start (progress, _("Shearing..."), FALSE); + + /* Shear the selection */ + success = gimp_drawable_transform_affine (drawable, context, + &matrix, GIMP_TRANSFORM_FORWARD, + interpolation_type, + interpolation, 3, + clip_result, progress); + + if (progress) + gimp_progress_end (progress); + } + } + + return_args = procedural_db_return_args (&drawable_transform_shear_defaults_proc, success); + + if (success) + return_args[1].value.pdb_int = gimp_item_get_ID (GIMP_ITEM (drawable)); + + return return_args; +} + +static ProcArg drawable_transform_shear_defaults_inargs[] = +{ + { + GIMP_PDB_DRAWABLE, + "drawable", + "The affected drawable" + }, + { + GIMP_PDB_INT32, + "shear_type", + "Type of shear: GIMP_ORIENTATION_HORIZONTAL (0) or GIMP_ORIENTATION_VERTICAL (1)" + }, + { + GIMP_PDB_FLOAT, + "magnitude", + "The magnitude of the shear" + }, + { + GIMP_PDB_INT32, + "interpolation", + "Whether to use interpolation and supersampling" + }, + { + GIMP_PDB_INT32, + "clip_result", + "Whether to clip results" + } +}; + +static ProcArg drawable_transform_shear_defaults_outargs[] = +{ + { + GIMP_PDB_DRAWABLE, + "drawable", + "The sheared drawable" + } +}; + +static ProcRecord drawable_transform_shear_defaults_proc = +{ + "gimp_drawable_transform_shear_defaults", + "Shear the specified drawable about its center by the specified magnitude, with extra parameters.", + "This procedure is a variant of gimp_drawable_transform_shear() which uses no interpolation/supersampling at all, or default values (depending on the 'interpolation' parameter).", + "João S. O. Bueno Calligaris", + "João S. O. Bueno Calligaris", + "2004", + NULL, + GIMP_INTERNAL, + 5, + drawable_transform_shear_defaults_inargs, + 1, + drawable_transform_shear_defaults_outargs, + { { drawable_transform_shear_defaults_invoker } } +}; + static Argument * drawable_transform_2d_invoker (Gimp *gimp, GimpContext *context, @@ -1323,6 +2055,172 @@ static ProcRecord drawable_transform_2d_proc = { { drawable_transform_2d_invoker } } }; +static Argument * +drawable_transform_2d_defaults_invoker (Gimp *gimp, + GimpContext *context, + GimpProgress *progress, + Argument *args) +{ + gboolean success = TRUE; + Argument *return_args; + GimpDrawable *drawable; + gdouble source_x; + gdouble source_y; + gdouble scale_x; + gdouble scale_y; + gdouble angle; + gdouble dest_x; + gdouble dest_y; + gboolean interpolation; + gboolean clip_result; + + drawable = (GimpDrawable *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int); + if (! (GIMP_IS_DRAWABLE (drawable) && ! gimp_item_is_removed (GIMP_ITEM (drawable)))) + success = FALSE; + + source_x = args[1].value.pdb_float; + + source_y = args[2].value.pdb_float; + + scale_x = args[3].value.pdb_float; + + scale_y = args[4].value.pdb_float; + + angle = args[5].value.pdb_float; + + dest_x = args[6].value.pdb_float; + + dest_y = args[7].value.pdb_float; + + interpolation = args[8].value.pdb_int ? TRUE : FALSE; + + clip_result = args[9].value.pdb_int ? TRUE : FALSE; + + if (success) + { + gint x, y, width, height; + + success = gimp_item_is_attached (GIMP_ITEM (drawable)); + + if (success && + gimp_drawable_mask_intersect (drawable, &x, &y, &width, &height)) + { + GimpMatrix3 matrix; + GimpInterpolationType interpolation_type = GIMP_INTERPOLATION_NONE; + + /* Assemble the transformation matrix */ + gimp_matrix3_identity (&matrix); + gimp_matrix3_translate (&matrix, -source_x, -source_y); + gimp_matrix3_scale (&matrix, scale_x, scale_y); + gimp_matrix3_rotate (&matrix, angle); + gimp_matrix3_translate (&matrix, dest_x, dest_y); + + if (interpolation) + interpolation_type = gimp->config->interpolation_type; + + if (progress) + gimp_progress_start (progress, _("2D Transform..."), FALSE); + + /* Transform the selection */ + success = gimp_drawable_transform_affine (drawable, context, + &matrix, GIMP_TRANSFORM_FORWARD, + interpolation_type, + interpolation, 3, + clip_result, progress); + + if (progress) + gimp_progress_end (progress); + } + } + + return_args = procedural_db_return_args (&drawable_transform_2d_defaults_proc, success); + + if (success) + return_args[1].value.pdb_int = gimp_item_get_ID (GIMP_ITEM (drawable)); + + return return_args; +} + +static ProcArg drawable_transform_2d_defaults_inargs[] = +{ + { + GIMP_PDB_DRAWABLE, + "drawable", + "The affected drawable" + }, + { + GIMP_PDB_FLOAT, + "source_x", + "X coordinate of the transformation center" + }, + { + GIMP_PDB_FLOAT, + "source_y", + "Y coordinate of the transformation center" + }, + { + GIMP_PDB_FLOAT, + "scale_x", + "Amount to scale in x direction" + }, + { + GIMP_PDB_FLOAT, + "scale_y", + "Amount to scale in y direction" + }, + { + GIMP_PDB_FLOAT, + "angle", + "The angle of rotation (radians)" + }, + { + GIMP_PDB_FLOAT, + "dest_x", + "X coordinate of where the center goes" + }, + { + GIMP_PDB_FLOAT, + "dest_y", + "Y coordinate of where the center goes" + }, + { + GIMP_PDB_INT32, + "interpolation", + "Whether to use interpolation and supersampling" + }, + { + GIMP_PDB_INT32, + "clip_result", + "Whether to clip results" + } +}; + +static ProcArg drawable_transform_2d_defaults_outargs[] = +{ + { + GIMP_PDB_DRAWABLE, + "drawable", + "The transformed drawable" + } +}; + +static ProcRecord drawable_transform_2d_defaults_proc = +{ + "gimp_drawable_transform_2d_defaults", + "Transform the specified drawable in 2d, with extra parameters.", + "This procedure is a variant of gimp_drawable_transform_2d() which uses no interpolation/supersampling at all, or default values (depending on the 'interpolation' parameter).", + "João S. O. Bueno Calligaris", + "João S. O. Bueno Calligaris", + "2004", + NULL, + GIMP_INTERNAL, + 10, + drawable_transform_2d_defaults_inargs, + 1, + drawable_transform_2d_defaults_outargs, + { { drawable_transform_2d_defaults_invoker } } +}; + static Argument * drawable_transform_matrix_invoker (Gimp *gimp, GimpContext *context, @@ -1534,3 +2432,189 @@ static ProcRecord drawable_transform_matrix_proc = drawable_transform_matrix_outargs, { { drawable_transform_matrix_invoker } } }; + +static Argument * +drawable_transform_matrix_defaults_invoker (Gimp *gimp, + GimpContext *context, + GimpProgress *progress, + Argument *args) +{ + gboolean success = TRUE; + Argument *return_args; + GimpDrawable *drawable; + gdouble coeff_0_0; + gdouble coeff_0_1; + gdouble coeff_0_2; + gdouble coeff_1_0; + gdouble coeff_1_1; + gdouble coeff_1_2; + gdouble coeff_2_0; + gdouble coeff_2_1; + gdouble coeff_2_2; + gboolean interpolation; + gboolean clip_result; + + drawable = (GimpDrawable *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int); + if (! (GIMP_IS_DRAWABLE (drawable) && ! gimp_item_is_removed (GIMP_ITEM (drawable)))) + success = FALSE; + + coeff_0_0 = args[1].value.pdb_float; + + coeff_0_1 = args[2].value.pdb_float; + + coeff_0_2 = args[3].value.pdb_float; + + coeff_1_0 = args[4].value.pdb_float; + + coeff_1_1 = args[5].value.pdb_float; + + coeff_1_2 = args[6].value.pdb_float; + + coeff_2_0 = args[7].value.pdb_float; + + coeff_2_1 = args[8].value.pdb_float; + + coeff_2_2 = args[9].value.pdb_float; + + interpolation = args[10].value.pdb_int ? TRUE : FALSE; + + clip_result = args[11].value.pdb_int ? TRUE : FALSE; + + if (success) + { + gint x, y, width, height; + + success = gimp_item_is_attached (GIMP_ITEM (drawable)); + + if (success && + gimp_drawable_mask_intersect (drawable, &x, &y, &width, &height)) + { + GimpMatrix3 matrix; + GimpInterpolationType interpolation_type = GIMP_INTERPOLATION_NONE; + + /* Assemble the transformation matrix */ + matrix.coeff[0][0] = coeff_0_0; + matrix.coeff[0][1] = coeff_0_1; + matrix.coeff[0][2] = coeff_0_2; + matrix.coeff[1][0] = coeff_1_0; + matrix.coeff[1][1] = coeff_1_1; + matrix.coeff[1][2] = coeff_1_2; + matrix.coeff[2][0] = coeff_2_0; + matrix.coeff[2][1] = coeff_2_1; + matrix.coeff[2][2] = coeff_2_2; + + if (interpolation) + interpolation_type = gimp->config->interpolation_type; + + if (progress) + gimp_progress_start (progress, _("2D Transform..."), FALSE); + + /* Transform the selection */ + success = gimp_drawable_transform_affine (drawable, context, + &matrix, GIMP_TRANSFORM_FORWARD, + interpolation_type, + interpolation, 3, + clip_result, progress); + + if (progress) + gimp_progress_end (progress); + } + } + + return_args = procedural_db_return_args (&drawable_transform_matrix_defaults_proc, success); + + if (success) + return_args[1].value.pdb_int = gimp_item_get_ID (GIMP_ITEM (drawable)); + + return return_args; +} + +static ProcArg drawable_transform_matrix_defaults_inargs[] = +{ + { + GIMP_PDB_DRAWABLE, + "drawable", + "The affected drawable" + }, + { + GIMP_PDB_FLOAT, + "coeff_0_0", + "coefficient (0,0) of the transformation matrix" + }, + { + GIMP_PDB_FLOAT, + "coeff_0_1", + "coefficient (0,1) of the transformation matrix" + }, + { + GIMP_PDB_FLOAT, + "coeff_0_2", + "coefficient (0,2) of the transformation matrix" + }, + { + GIMP_PDB_FLOAT, + "coeff_1_0", + "coefficient (1,0) of the transformation matrix" + }, + { + GIMP_PDB_FLOAT, + "coeff_1_1", + "coefficient (1,1) of the transformation matrix" + }, + { + GIMP_PDB_FLOAT, + "coeff_1_2", + "coefficient (1,2) of the transformation matrix" + }, + { + GIMP_PDB_FLOAT, + "coeff_2_0", + "coefficient (2,0) of the transformation matrix" + }, + { + GIMP_PDB_FLOAT, + "coeff_2_1", + "coefficient (2,1) of the transformation matrix" + }, + { + GIMP_PDB_FLOAT, + "coeff_2_2", + "coefficient (2,2) of the transformation matrix" + }, + { + GIMP_PDB_INT32, + "interpolation", + "Whether to use interpolation and supersampling" + }, + { + GIMP_PDB_INT32, + "clip_result", + "Whether to clip results" + } +}; + +static ProcArg drawable_transform_matrix_defaults_outargs[] = +{ + { + GIMP_PDB_DRAWABLE, + "drawable", + "The transformed drawable" + } +}; + +static ProcRecord drawable_transform_matrix_defaults_proc = +{ + "gimp_drawable_transform_matrix_defaults", + "Transform the specified drawable in 2d, with extra parameters.", + "This procedure is a variant of gimp_drawable_transform_matrix() which uses no interpolation/supersampling at all, or default values (depending on the 'interpolation' parameter).", + "João S. O. Bueno Calligaris", + "João S. O. Bueno Calligaris", + "2004", + NULL, + GIMP_INTERNAL, + 12, + drawable_transform_matrix_defaults_inargs, + 1, + drawable_transform_matrix_defaults_outargs, + { { drawable_transform_matrix_defaults_invoker } } +}; diff --git a/app/pdb/internal_procs.c b/app/pdb/internal_procs.c index 4c98fc57eb..241ecfce2f 100644 --- a/app/pdb/internal_procs.c +++ b/app/pdb/internal_procs.c @@ -74,7 +74,7 @@ void register_transform_tools_procs (Gimp *gimp); void register_undo_procs (Gimp *gimp); void register_unit_procs (Gimp *gimp); -/* 425 procedures registered total */ +/* 432 procedures registered total */ void internal_procs_init (Gimp *gimp, @@ -89,124 +89,124 @@ internal_procs_init (Gimp *gimp, (* status_callback) (NULL, _("Brush UI"), 0.019); register_brush_select_procs (gimp); - (* status_callback) (NULL, _("Brushes"), 0.026); + (* status_callback) (NULL, _("Brushes"), 0.025); register_brushes_procs (gimp); - (* status_callback) (NULL, _("Channel"), 0.04); + (* status_callback) (NULL, _("Channel"), 0.039); register_channel_procs (gimp); - (* status_callback) (NULL, _("Color"), 0.061); + (* status_callback) (NULL, _("Color"), 0.06); register_color_procs (gimp); - (* status_callback) (NULL, _("Context"), 0.096); + (* status_callback) (NULL, _("Context"), 0.095); register_context_procs (gimp); - (* status_callback) (NULL, _("Convert"), 0.148); + (* status_callback) (NULL, _("Convert"), 0.146); register_convert_procs (gimp); - (* status_callback) (NULL, _("Display procedures"), 0.155); + (* status_callback) (NULL, _("Display procedures"), 0.153); register_display_procs (gimp); - (* status_callback) (NULL, _("Drawable procedures"), 0.165); + (* status_callback) (NULL, _("Drawable procedures"), 0.162); register_drawable_procs (gimp); - (* status_callback) (NULL, _("Transformation procedures"), 0.242); + (* status_callback) (NULL, _("Transformation procedures"), 0.238); register_drawable_transform_procs (gimp); - (* status_callback) (NULL, _("Edit procedures"), 0.264); + (* status_callback) (NULL, _("Edit procedures"), 0.275); register_edit_procs (gimp); - (* status_callback) (NULL, _("File Operations"), 0.282); + (* status_callback) (NULL, _("File Operations"), 0.294); register_fileops_procs (gimp); - (* status_callback) (NULL, _("Floating selections"), 0.304); + (* status_callback) (NULL, _("Floating selections"), 0.315); register_floating_sel_procs (gimp); - (* status_callback) (NULL, _("Font UI"), 0.318); + (* status_callback) (NULL, _("Font UI"), 0.329); register_font_select_procs (gimp); - (* status_callback) (NULL, _("Fonts"), 0.325); + (* status_callback) (NULL, _("Fonts"), 0.336); register_fonts_procs (gimp); - (* status_callback) (NULL, _("Gimprc procedures"), 0.329); + (* status_callback) (NULL, _("Gimprc procedures"), 0.34); register_gimprc_procs (gimp); - (* status_callback) (NULL, _("Gradient"), 0.344); + (* status_callback) (NULL, _("Gradient"), 0.354); register_gradient_procs (gimp); - (* status_callback) (NULL, _("Gradient UI"), 0.412); + (* status_callback) (NULL, _("Gradient UI"), 0.421); register_gradient_select_procs (gimp); - (* status_callback) (NULL, _("Gradients"), 0.419); + (* status_callback) (NULL, _("Gradients"), 0.428); register_gradients_procs (gimp); - (* status_callback) (NULL, _("Guide procedures"), 0.431); + (* status_callback) (NULL, _("Guide procedures"), 0.44); register_guides_procs (gimp); - (* status_callback) (NULL, _("Help procedures"), 0.445); + (* status_callback) (NULL, _("Help procedures"), 0.454); register_help_procs (gimp); - (* status_callback) (NULL, _("Image"), 0.447); + (* status_callback) (NULL, _("Image"), 0.456); register_image_procs (gimp); - (* status_callback) (NULL, _("Layer"), 0.598); + (* status_callback) (NULL, _("Layer"), 0.604); register_layer_procs (gimp); - (* status_callback) (NULL, _("Message procedures"), 0.659); + (* status_callback) (NULL, _("Message procedures"), 0.664); register_message_procs (gimp); - (* status_callback) (NULL, _("Miscellaneous"), 0.666); + (* status_callback) (NULL, _("Miscellaneous"), 0.671); register_misc_procs (gimp); - (* status_callback) (NULL, _("Paint Tool procedures"), 0.671); + (* status_callback) (NULL, _("Paint Tool procedures"), 0.676); register_paint_tools_procs (gimp); - (* status_callback) (NULL, _("Palette"), 0.706); + (* status_callback) (NULL, _("Palette"), 0.711); register_palette_procs (gimp); - (* status_callback) (NULL, _("Palette UI"), 0.732); + (* status_callback) (NULL, _("Palette UI"), 0.736); register_palette_select_procs (gimp); - (* status_callback) (NULL, _("Palettes"), 0.739); + (* status_callback) (NULL, _("Palettes"), 0.743); register_palettes_procs (gimp); - (* status_callback) (NULL, _("Parasite procedures"), 0.748); + (* status_callback) (NULL, _("Parasite procedures"), 0.752); register_parasite_procs (gimp); - (* status_callback) (NULL, _("Paths"), 0.776); + (* status_callback) (NULL, _("Paths"), 0.78); register_paths_procs (gimp); - (* status_callback) (NULL, _("Pattern"), 0.812); + (* status_callback) (NULL, _("Pattern"), 0.815); register_pattern_procs (gimp); - (* status_callback) (NULL, _("Pattern UI"), 0.816); + (* status_callback) (NULL, _("Pattern UI"), 0.819); register_pattern_select_procs (gimp); - (* status_callback) (NULL, _("Patterns"), 0.824); + (* status_callback) (NULL, _("Patterns"), 0.826); register_patterns_procs (gimp); - (* status_callback) (NULL, _("Plug-in"), 0.833); + (* status_callback) (NULL, _("Plug-in"), 0.836); register_plug_in_procs (gimp); - (* status_callback) (NULL, _("Procedural database"), 0.845); + (* status_callback) (NULL, _("Procedural database"), 0.847); register_procedural_db_procs (gimp); - (* status_callback) (NULL, _("Progress"), 0.866); + (* status_callback) (NULL, _("Progress"), 0.868); register_progress_procs (gimp); - (* status_callback) (NULL, _("Image mask"), 0.878); + (* status_callback) (NULL, _("Image mask"), 0.88); register_selection_procs (gimp); - (* status_callback) (NULL, _("Selection Tool procedures"), 0.92); + (* status_callback) (NULL, _("Selection Tool procedures"), 0.921); register_selection_tools_procs (gimp); - (* status_callback) (NULL, _("Text procedures"), 0.932); + (* status_callback) (NULL, _("Text procedures"), 0.933); register_text_tool_procs (gimp); - (* status_callback) (NULL, _("Transform Tool procedures"), 0.941); + (* status_callback) (NULL, _("Transform Tool procedures"), 0.942); register_transform_tools_procs (gimp); - (* status_callback) (NULL, _("Undo"), 0.955); + (* status_callback) (NULL, _("Undo"), 0.956); register_undo_procs (gimp); (* status_callback) (NULL, _("Units"), 0.972); diff --git a/libgimp/gimp.def b/libgimp/gimp.def index 6e4a40b11d..72db0a5b54 100644 --- a/libgimp/gimp.def +++ b/libgimp/gimp.def @@ -133,13 +133,20 @@ EXPORTS gimp_drawable_set_visible gimp_drawable_transform_flip_simple gimp_drawable_transform_flip + gimp_drawable_transform_flip_defaults gimp_drawable_transform_perspective + gimp_drawable_transform_perspective_defaults gimp_drawable_transform_rotate_simple gimp_drawable_transform_rotate + gimp_drawable_transform_rotate_defaults gimp_drawable_transform_scale + gimp_drawable_transform_scale_defaults gimp_drawable_transform_shear + gimp_drawable_transform_shear_defaults gimp_drawable_transform_2d + gimp_drawable_transform_2d_defaults gimp_drawable_transform_matrix + gimp_drawable_transform_matrix_defaults gimp_drawable_type gimp_drawable_type_with_alpha gimp_drawable_update diff --git a/libgimp/gimpdrawabletransform_pdb.c b/libgimp/gimpdrawabletransform_pdb.c index 0900c0461c..e21070c776 100644 --- a/libgimp/gimpdrawabletransform_pdb.c +++ b/libgimp/gimpdrawabletransform_pdb.c @@ -145,6 +145,58 @@ gimp_drawable_transform_flip (gint32 drawable_ID, return ret_drawable_ID; } +/** + * gimp_drawable_transform_flip_defaults: + * @drawable_ID: The affected drawable. + * @x0: horz. coord. of one end of axis. + * @y0: vert. coord. of one end of axis. + * @x1: horz. coord. of other end of axis. + * @y1: vert. coord. of other end of axis. + * @interpolation: Whether to use interpolation and supersampling. + * @clip_result: Whether to clip results. + * + * Flip the specified drawable around a given line. + * + * This procedure is a variant of gimp_drawable_transform_flip() which + * uses no interpolation/supersampling at all, or default values + * (depending on the 'interpolation' parameter). + * + * Returns: The flipped drawable. + * + * Since: GIMP 2.2 + */ +gint32 +gimp_drawable_transform_flip_defaults (gint32 drawable_ID, + gdouble x0, + gdouble y0, + gdouble x1, + gdouble y1, + gboolean interpolation, + gboolean clip_result) +{ + GimpParam *return_vals; + gint nreturn_vals; + gint32 ret_drawable_ID = -1; + + return_vals = gimp_run_procedure ("gimp_drawable_transform_flip_defaults", + &nreturn_vals, + GIMP_PDB_DRAWABLE, drawable_ID, + GIMP_PDB_FLOAT, x0, + GIMP_PDB_FLOAT, y0, + GIMP_PDB_FLOAT, x1, + GIMP_PDB_FLOAT, y1, + GIMP_PDB_INT32, interpolation, + GIMP_PDB_INT32, clip_result, + GIMP_PDB_END); + + if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS) + ret_drawable_ID = return_vals[1].data.d_drawable; + + gimp_destroy_params (return_vals, nreturn_vals); + + return ret_drawable_ID; +} + /** * gimp_drawable_transform_perspective: * @drawable_ID: The affected drawable. @@ -231,6 +283,71 @@ gimp_drawable_transform_perspective (gint32 drawable_ID, return ret_drawable_ID; } +/** + * gimp_drawable_transform_perspective_defaults: + * @drawable_ID: The affected drawable. + * @x0: The new x coordinate of upper-left corner of original bounding box. + * @y0: The new y coordinate of upper-left corner of original bounding box. + * @x1: The new x coordinate of upper-right corner of original bounding box. + * @y1: The new y coordinate of upper-right corner of original bounding box. + * @x2: The new x coordinate of lower-left corner of original bounding box. + * @y2: The new y coordinate of lower-left corner of original bounding box. + * @x3: The new x coordinate of lower-right corner of original bounding box. + * @y3: The new y coordinate of lower-right corner of original bounding box. + * @interpolation: Whether to use interpolation and supersampling. + * @clip_result: Whether to clip results. + * + * Perform a possibly non-affine transformation on the specified + * drawable, with extra parameters. + * + * This procedure is a variant of gimp_drawable_transform_perspective() + * which uses no interpolation/supersampling at all, or default values + * (depending on the 'interpolation' parameter). + * + * Returns: The newly mapped drawable. + * + * Since: GIMP 2.2 + */ +gint32 +gimp_drawable_transform_perspective_defaults (gint32 drawable_ID, + gdouble x0, + gdouble y0, + gdouble x1, + gdouble y1, + gdouble x2, + gdouble y2, + gdouble x3, + gdouble y3, + gboolean interpolation, + gboolean clip_result) +{ + GimpParam *return_vals; + gint nreturn_vals; + gint32 ret_drawable_ID = -1; + + return_vals = gimp_run_procedure ("gimp_drawable_transform_perspective_defaults", + &nreturn_vals, + GIMP_PDB_DRAWABLE, drawable_ID, + GIMP_PDB_FLOAT, x0, + GIMP_PDB_FLOAT, y0, + GIMP_PDB_FLOAT, x1, + GIMP_PDB_FLOAT, y1, + GIMP_PDB_FLOAT, x2, + GIMP_PDB_FLOAT, y2, + GIMP_PDB_FLOAT, x3, + GIMP_PDB_FLOAT, y3, + GIMP_PDB_INT32, interpolation, + GIMP_PDB_INT32, clip_result, + GIMP_PDB_END); + + if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS) + ret_drawable_ID = return_vals[1].data.d_drawable; + + gimp_destroy_params (return_vals, nreturn_vals); + + return ret_drawable_ID; +} + /** * gimp_drawable_transform_rotate_simple: * @drawable_ID: The affected drawable. @@ -351,6 +468,59 @@ gimp_drawable_transform_rotate (gint32 drawable_ID, return ret_drawable_ID; } +/** + * gimp_drawable_transform_rotate_defaults: + * @drawable_ID: The affected drawable. + * @angle: The angle of rotation (radians). + * @auto_center: Whether to automatically rotate around the selection center. + * @center_x: The hor. coordinate of the center of rotation. + * @center_y: The vert. coordinate of the center of rotation. + * @interpolation: Whether to use interpolation and supersampling. + * @clip_result: Whether to clip results. + * + * Rotate the specified drawable about given coordinates through the + * specified angle. + * + * This procedure is a variant of gimp_drawable_transform_rotate() + * which uses no interpolation/supersampling at all, or default values + * (depending on the 'interpolation' parameter). + * + * Returns: The rotated drawable. + * + * Since: GIMP 2.2 + */ +gint32 +gimp_drawable_transform_rotate_defaults (gint32 drawable_ID, + gdouble angle, + gboolean auto_center, + gint center_x, + gint center_y, + gboolean interpolation, + gboolean clip_result) +{ + GimpParam *return_vals; + gint nreturn_vals; + gint32 ret_drawable_ID = -1; + + return_vals = gimp_run_procedure ("gimp_drawable_transform_rotate_defaults", + &nreturn_vals, + GIMP_PDB_DRAWABLE, drawable_ID, + GIMP_PDB_FLOAT, angle, + GIMP_PDB_INT32, auto_center, + GIMP_PDB_INT32, center_x, + GIMP_PDB_INT32, center_y, + GIMP_PDB_INT32, interpolation, + GIMP_PDB_INT32, clip_result, + GIMP_PDB_END); + + if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS) + ret_drawable_ID = return_vals[1].data.d_drawable; + + gimp_destroy_params (return_vals, nreturn_vals); + + return ret_drawable_ID; +} + /** * gimp_drawable_transform_scale: * @drawable_ID: The affected drawable. @@ -416,6 +586,58 @@ gimp_drawable_transform_scale (gint32 drawable_ID, return ret_drawable_ID; } +/** + * gimp_drawable_transform_scale_defaults: + * @drawable_ID: The affected drawable. + * @x0: The new x coordinate of upper-left corner of newly scaled region. + * @y0: The new y coordinate of upper-left corner of newly scaled region. + * @x1: The new x coordinate of lower-right corner of newly scaled region. + * @y1: The new y coordinate of lower-right corner of newly scaled region. + * @interpolation: Whether to use interpolation and supersampling. + * @clip_result: Whether to clip results. + * + * Scale the specified drawable with extra parameters + * + * This procedure is a variant of gimp_drawable_transform_scale() which + * uses no interpolation/supersampling at all, or default values + * (depending on the 'interpolation' parameter). + * + * Returns: The scaled drawable. + * + * Since: GIMP 2.2 + */ +gint32 +gimp_drawable_transform_scale_defaults (gint32 drawable_ID, + gdouble x0, + gdouble y0, + gdouble x1, + gdouble y1, + gboolean interpolation, + gboolean clip_result) +{ + GimpParam *return_vals; + gint nreturn_vals; + gint32 ret_drawable_ID = -1; + + return_vals = gimp_run_procedure ("gimp_drawable_transform_scale_defaults", + &nreturn_vals, + GIMP_PDB_DRAWABLE, drawable_ID, + GIMP_PDB_FLOAT, x0, + GIMP_PDB_FLOAT, y0, + GIMP_PDB_FLOAT, x1, + GIMP_PDB_FLOAT, y1, + GIMP_PDB_INT32, interpolation, + GIMP_PDB_INT32, clip_result, + GIMP_PDB_END); + + if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS) + ret_drawable_ID = return_vals[1].data.d_drawable; + + gimp_destroy_params (return_vals, nreturn_vals); + + return ret_drawable_ID; +} + /** * gimp_drawable_transform_shear: * @drawable_ID: The affected drawable. @@ -479,6 +701,53 @@ gimp_drawable_transform_shear (gint32 drawable_ID, return ret_drawable_ID; } +/** + * gimp_drawable_transform_shear_defaults: + * @drawable_ID: The affected drawable. + * @shear_type: Type of shear. + * @magnitude: The magnitude of the shear. + * @interpolation: Whether to use interpolation and supersampling. + * @clip_result: Whether to clip results. + * + * Shear the specified drawable about its center by the specified + * magnitude, with extra parameters. + * + * This procedure is a variant of gimp_drawable_transform_shear() which + * uses no interpolation/supersampling at all, or default values + * (depending on the 'interpolation' parameter). + * + * Returns: The sheared drawable. + * + * Since: GIMP 2.2 + */ +gint32 +gimp_drawable_transform_shear_defaults (gint32 drawable_ID, + GimpOrientationType shear_type, + gdouble magnitude, + gboolean interpolation, + gboolean clip_result) +{ + GimpParam *return_vals; + gint nreturn_vals; + gint32 ret_drawable_ID = -1; + + return_vals = gimp_run_procedure ("gimp_drawable_transform_shear_defaults", + &nreturn_vals, + GIMP_PDB_DRAWABLE, drawable_ID, + GIMP_PDB_INT32, shear_type, + GIMP_PDB_FLOAT, magnitude, + GIMP_PDB_INT32, interpolation, + GIMP_PDB_INT32, clip_result, + GIMP_PDB_END); + + if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS) + ret_drawable_ID = return_vals[1].data.d_drawable; + + gimp_destroy_params (return_vals, nreturn_vals); + + return ret_drawable_ID; +} + /** * gimp_drawable_transform_2d: * @drawable_ID: The affected drawable. @@ -556,6 +825,67 @@ gimp_drawable_transform_2d (gint32 drawable_ID, return ret_drawable_ID; } +/** + * gimp_drawable_transform_2d_defaults: + * @drawable_ID: The affected drawable. + * @source_x: X coordinate of the transformation center. + * @source_y: Y coordinate of the transformation center. + * @scale_x: Amount to scale in x direction. + * @scale_y: Amount to scale in y direction. + * @angle: The angle of rotation (radians). + * @dest_x: X coordinate of where the center goes. + * @dest_y: Y coordinate of where the center goes. + * @interpolation: Whether to use interpolation and supersampling. + * @clip_result: Whether to clip results. + * + * Transform the specified drawable in 2d, with extra parameters. + * + * This procedure is a variant of gimp_drawable_transform_2d() which + * uses no interpolation/supersampling at all, or default values + * (depending on the 'interpolation' parameter). + * + * Returns: The transformed drawable. + * + * Since: GIMP 2.2 + */ +gint32 +gimp_drawable_transform_2d_defaults (gint32 drawable_ID, + gdouble source_x, + gdouble source_y, + gdouble scale_x, + gdouble scale_y, + gdouble angle, + gdouble dest_x, + gdouble dest_y, + gboolean interpolation, + gboolean clip_result) +{ + GimpParam *return_vals; + gint nreturn_vals; + gint32 ret_drawable_ID = -1; + + return_vals = gimp_run_procedure ("gimp_drawable_transform_2d_defaults", + &nreturn_vals, + GIMP_PDB_DRAWABLE, drawable_ID, + GIMP_PDB_FLOAT, source_x, + GIMP_PDB_FLOAT, source_y, + GIMP_PDB_FLOAT, scale_x, + GIMP_PDB_FLOAT, scale_y, + GIMP_PDB_FLOAT, angle, + GIMP_PDB_FLOAT, dest_x, + GIMP_PDB_FLOAT, dest_y, + GIMP_PDB_INT32, interpolation, + GIMP_PDB_INT32, clip_result, + GIMP_PDB_END); + + if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS) + ret_drawable_ID = return_vals[1].data.d_drawable; + + gimp_destroy_params (return_vals, nreturn_vals); + + return ret_drawable_ID; +} + /** * gimp_drawable_transform_matrix: * @drawable_ID: The affected drawable. @@ -636,3 +966,70 @@ gimp_drawable_transform_matrix (gint32 drawable_ID, return ret_drawable_ID; } + +/** + * gimp_drawable_transform_matrix_defaults: + * @drawable_ID: The affected drawable. + * @coeff_0_0: coefficient (0,0) of the transformation matrix. + * @coeff_0_1: coefficient (0,1) of the transformation matrix. + * @coeff_0_2: coefficient (0,2) of the transformation matrix. + * @coeff_1_0: coefficient (1,0) of the transformation matrix. + * @coeff_1_1: coefficient (1,1) of the transformation matrix. + * @coeff_1_2: coefficient (1,2) of the transformation matrix. + * @coeff_2_0: coefficient (2,0) of the transformation matrix. + * @coeff_2_1: coefficient (2,1) of the transformation matrix. + * @coeff_2_2: coefficient (2,2) of the transformation matrix. + * @interpolation: Whether to use interpolation and supersampling. + * @clip_result: Whether to clip results. + * + * Transform the specified drawable in 2d, with extra parameters. + * + * This procedure is a variant of gimp_drawable_transform_matrix() + * which uses no interpolation/supersampling at all, or default values + * (depending on the 'interpolation' parameter). + * + * Returns: The transformed drawable. + * + * Since: GIMP 2.2 + */ +gint32 +gimp_drawable_transform_matrix_defaults (gint32 drawable_ID, + gdouble coeff_0_0, + gdouble coeff_0_1, + gdouble coeff_0_2, + gdouble coeff_1_0, + gdouble coeff_1_1, + gdouble coeff_1_2, + gdouble coeff_2_0, + gdouble coeff_2_1, + gdouble coeff_2_2, + gboolean interpolation, + gboolean clip_result) +{ + GimpParam *return_vals; + gint nreturn_vals; + gint32 ret_drawable_ID = -1; + + return_vals = gimp_run_procedure ("gimp_drawable_transform_matrix_defaults", + &nreturn_vals, + GIMP_PDB_DRAWABLE, drawable_ID, + GIMP_PDB_FLOAT, coeff_0_0, + GIMP_PDB_FLOAT, coeff_0_1, + GIMP_PDB_FLOAT, coeff_0_2, + GIMP_PDB_FLOAT, coeff_1_0, + GIMP_PDB_FLOAT, coeff_1_1, + GIMP_PDB_FLOAT, coeff_1_2, + GIMP_PDB_FLOAT, coeff_2_0, + GIMP_PDB_FLOAT, coeff_2_1, + GIMP_PDB_FLOAT, coeff_2_2, + GIMP_PDB_INT32, interpolation, + GIMP_PDB_INT32, clip_result, + GIMP_PDB_END); + + if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS) + ret_drawable_ID = return_vals[1].data.d_drawable; + + gimp_destroy_params (return_vals, nreturn_vals); + + return ret_drawable_ID; +} diff --git a/libgimp/gimpdrawabletransform_pdb.h b/libgimp/gimpdrawabletransform_pdb.h index 041db93bce..0ad57f3b49 100644 --- a/libgimp/gimpdrawabletransform_pdb.h +++ b/libgimp/gimpdrawabletransform_pdb.h @@ -29,97 +29,156 @@ G_BEGIN_DECLS /* For information look into the C source or the html documentation */ -gint32 gimp_drawable_transform_flip_simple (gint32 drawable_ID, - GimpOrientationType flip_type, - gboolean auto_center, - gdouble axis, - gboolean clip_result); -gint32 gimp_drawable_transform_flip (gint32 drawable_ID, - gdouble x0, - gdouble y0, - gdouble x1, - gdouble y1, - GimpTransformDirection transform_direction, - GimpInterpolationType interpolation, - gboolean supersample, - gint recursion_level, - gboolean clip_result); -gint32 gimp_drawable_transform_perspective (gint32 drawable_ID, - gdouble x0, - gdouble y0, - gdouble x1, - gdouble y1, - gdouble x2, - gdouble y2, - gdouble x3, - gdouble y3, - GimpTransformDirection transform_direction, - GimpInterpolationType interpolation, - gboolean supersample, - gint recursion_level, - gboolean clip_result); -gint32 gimp_drawable_transform_rotate_simple (gint32 drawable_ID, - GimpRotationType rotate_type, - gboolean auto_center, - gint center_x, - gint center_y, - gboolean clip_result); -gint32 gimp_drawable_transform_rotate (gint32 drawable_ID, - gdouble angle, - gboolean auto_center, - gint center_x, - gint center_y, - GimpTransformDirection transform_direction, - GimpInterpolationType interpolation, - gboolean supersample, - gint recursion_level, - gboolean clip_result); -gint32 gimp_drawable_transform_scale (gint32 drawable_ID, - gdouble x0, - gdouble y0, - gdouble x1, - gdouble y1, - GimpTransformDirection transform_direction, - GimpInterpolationType interpolation, - gboolean supersample, - gint recursion_level, - gboolean clip_result); -gint32 gimp_drawable_transform_shear (gint32 drawable_ID, - GimpOrientationType shear_type, - gdouble magnitude, - GimpTransformDirection transform_direction, - GimpInterpolationType interpolation, - gboolean supersample, - gint recursion_level, - gboolean clip_result); -gint32 gimp_drawable_transform_2d (gint32 drawable_ID, - gdouble source_x, - gdouble source_y, - gdouble scale_x, - gdouble scale_y, - gdouble angle, - gdouble dest_x, - gdouble dest_y, - GimpTransformDirection transform_direction, - GimpInterpolationType interpolation, - gboolean supersample, - gint recursion_level, - gboolean clip_result); -gint32 gimp_drawable_transform_matrix (gint32 drawable_ID, - gdouble coeff_0_0, - gdouble coeff_0_1, - gdouble coeff_0_2, - gdouble coeff_1_0, - gdouble coeff_1_1, - gdouble coeff_1_2, - gdouble coeff_2_0, - gdouble coeff_2_1, - gdouble coeff_2_2, - GimpTransformDirection transform_direction, - GimpInterpolationType interpolation, - gboolean supersample, - gint recursion_level, - gboolean clip_result); +gint32 gimp_drawable_transform_flip_simple (gint32 drawable_ID, + GimpOrientationType flip_type, + gboolean auto_center, + gdouble axis, + gboolean clip_result); +gint32 gimp_drawable_transform_flip (gint32 drawable_ID, + gdouble x0, + gdouble y0, + gdouble x1, + gdouble y1, + GimpTransformDirection transform_direction, + GimpInterpolationType interpolation, + gboolean supersample, + gint recursion_level, + gboolean clip_result); +gint32 gimp_drawable_transform_flip_defaults (gint32 drawable_ID, + gdouble x0, + gdouble y0, + gdouble x1, + gdouble y1, + gboolean interpolation, + gboolean clip_result); +gint32 gimp_drawable_transform_perspective (gint32 drawable_ID, + gdouble x0, + gdouble y0, + gdouble x1, + gdouble y1, + gdouble x2, + gdouble y2, + gdouble x3, + gdouble y3, + GimpTransformDirection transform_direction, + GimpInterpolationType interpolation, + gboolean supersample, + gint recursion_level, + gboolean clip_result); +gint32 gimp_drawable_transform_perspective_defaults (gint32 drawable_ID, + gdouble x0, + gdouble y0, + gdouble x1, + gdouble y1, + gdouble x2, + gdouble y2, + gdouble x3, + gdouble y3, + gboolean interpolation, + gboolean clip_result); +gint32 gimp_drawable_transform_rotate_simple (gint32 drawable_ID, + GimpRotationType rotate_type, + gboolean auto_center, + gint center_x, + gint center_y, + gboolean clip_result); +gint32 gimp_drawable_transform_rotate (gint32 drawable_ID, + gdouble angle, + gboolean auto_center, + gint center_x, + gint center_y, + GimpTransformDirection transform_direction, + GimpInterpolationType interpolation, + gboolean supersample, + gint recursion_level, + gboolean clip_result); +gint32 gimp_drawable_transform_rotate_defaults (gint32 drawable_ID, + gdouble angle, + gboolean auto_center, + gint center_x, + gint center_y, + gboolean interpolation, + gboolean clip_result); +gint32 gimp_drawable_transform_scale (gint32 drawable_ID, + gdouble x0, + gdouble y0, + gdouble x1, + gdouble y1, + GimpTransformDirection transform_direction, + GimpInterpolationType interpolation, + gboolean supersample, + gint recursion_level, + gboolean clip_result); +gint32 gimp_drawable_transform_scale_defaults (gint32 drawable_ID, + gdouble x0, + gdouble y0, + gdouble x1, + gdouble y1, + gboolean interpolation, + gboolean clip_result); +gint32 gimp_drawable_transform_shear (gint32 drawable_ID, + GimpOrientationType shear_type, + gdouble magnitude, + GimpTransformDirection transform_direction, + GimpInterpolationType interpolation, + gboolean supersample, + gint recursion_level, + gboolean clip_result); +gint32 gimp_drawable_transform_shear_defaults (gint32 drawable_ID, + GimpOrientationType shear_type, + gdouble magnitude, + gboolean interpolation, + gboolean clip_result); +gint32 gimp_drawable_transform_2d (gint32 drawable_ID, + gdouble source_x, + gdouble source_y, + gdouble scale_x, + gdouble scale_y, + gdouble angle, + gdouble dest_x, + gdouble dest_y, + GimpTransformDirection transform_direction, + GimpInterpolationType interpolation, + gboolean supersample, + gint recursion_level, + gboolean clip_result); +gint32 gimp_drawable_transform_2d_defaults (gint32 drawable_ID, + gdouble source_x, + gdouble source_y, + gdouble scale_x, + gdouble scale_y, + gdouble angle, + gdouble dest_x, + gdouble dest_y, + gboolean interpolation, + gboolean clip_result); +gint32 gimp_drawable_transform_matrix (gint32 drawable_ID, + gdouble coeff_0_0, + gdouble coeff_0_1, + gdouble coeff_0_2, + gdouble coeff_1_0, + gdouble coeff_1_1, + gdouble coeff_1_2, + gdouble coeff_2_0, + gdouble coeff_2_1, + gdouble coeff_2_2, + GimpTransformDirection transform_direction, + GimpInterpolationType interpolation, + gboolean supersample, + gint recursion_level, + gboolean clip_result); +gint32 gimp_drawable_transform_matrix_defaults (gint32 drawable_ID, + gdouble coeff_0_0, + gdouble coeff_0_1, + gdouble coeff_0_2, + gdouble coeff_1_0, + gdouble coeff_1_1, + gdouble coeff_1_2, + gdouble coeff_2_0, + gdouble coeff_2_1, + gdouble coeff_2_2, + gboolean interpolation, + gboolean clip_result); G_END_DECLS diff --git a/tools/pdbgen/pdb/drawable_transform.pdb b/tools/pdbgen/pdb/drawable_transform.pdb index 21005fc20a..d02b88841f 100644 --- a/tools/pdbgen/pdb/drawable_transform.pdb +++ b/tools/pdbgen/pdb/drawable_transform.pdb @@ -48,6 +48,13 @@ sub transform_options_args () { desc => 'Whether to clip results' } } +sub transform_options_defaults_args () { + { name => 'interpolation', type => 'boolean', + desc => 'Whether to use interpolation and supersampling' }, + { name => 'clip_result', type => 'boolean', + desc => 'Whether to clip results' } +} + sub drawable_out_arg { my $type = shift; my $arg = &drawable_arg; @@ -144,8 +151,7 @@ HELP desc => 'horz. coord. of other end of axis' }, { name => 'y1', type => 'float', desc => 'vert. coord. of other end of axis' }, - - &transform_options_args + &transform_options_args ); @outargs = ( &drawable_out_arg('flipped') ); @@ -185,6 +191,73 @@ CODE } +sub drawable_transform_flip_defaults { + $blurb = <<'BLURB'; +Flip the specified drawable around a given line. +BLURB + + $help = <<'HELP'; +This procedure is a variant of gimp_drawable_transform_flip() which +uses no interpolation/supersampling at all, or default values +(depending on the 'interpolation' parameter). +HELP + + &pdb_misc; + + @inargs = ( + &drawable_arg, + { name => 'x0', type => 'float', + desc => 'horz. coord. of one end of axis' }, + { name => 'y0', type => 'float', + desc => 'vert. coord. of one end of axis' }, + { name => 'x1', type => 'float', + desc => 'horz. coord. of other end of axis' }, + { name => 'y1', type => 'float', + desc => 'vert. coord. of other end of axis' }, + &transform_options_defaults_args + ); + + @outargs = ( &drawable_out_arg('flipped') ); + + %invoke = ( + code => <<'CODE' +{ + gint x, y, width, height; + + success = gimp_item_is_attached (GIMP_ITEM (drawable)); + + if (success && + gimp_drawable_mask_intersect (drawable, &x, &y, &width, &height)) + { + GimpMatrix3 matrix; + GimpInterpolationType interpolation_type = GIMP_INTERPOLATION_NONE; + + /* Assemble the transformation matrix */ + gimp_transform_matrix_flip_free (x, y, width, height, + x0, y0, x1, y1, + &matrix); + + if (interpolation) + interpolation_type = gimp->config->interpolation_type; + + if (progress) + gimp_progress_start (progress, _("Flip..."), FALSE); + + /* Transform the selection */ + success = gimp_drawable_transform_affine (drawable, context, + &matrix, GIMP_TRANSFORM_FORWARD, + interpolation_type, + interpolation, 3, + clip_result, progress); + if (progress) + gimp_progress_end (progress); + } +} +CODE + ); +} + + sub drawable_transform_perspective { $blurb = <<'BLURB'; Perform a possibly non-affine transformation on the specified drawable, with extra parameters. @@ -226,7 +299,7 @@ HELP $pos++; } @inargs = (@inargs, - &transform_options_args + &transform_options_args ); @outargs = ( &drawable_out_arg('newly mapped') ); @@ -270,6 +343,85 @@ CODE ); } + +sub drawable_transform_perspective_defaults { + $blurb = <<'BLURB'; +Perform a possibly non-affine transformation on the specified drawable, with extra parameters. +BLURB + + $help = <<'HELP'; +This procedure is a variant of gimp_drawable_transform_perspective() which +uses no interpolation/supersampling at all, or default values +(depending on the 'interpolation' parameter). +HELP + + &pdb_misc; + + @inargs = ( + &drawable_arg + ); + + my $pos = 0; + foreach $where (qw(upper-left upper-right lower-left lower-right)) { + foreach (qw(x y)) { + push @inargs, + { name => "$_$pos", type => 'float', + desc => "The new $_ coordinate of $where corner of original + bounding box", + alias => "trans_info[\U$_\E$pos]", no_declare => 1 } + } + $pos++; + } + @inargs = (@inargs, + &transform_options_defaults_args + ); + + @outargs = ( &drawable_out_arg('newly mapped') ); + + %invoke = ( + vars => [ 'gdouble trans_info[8]' ], + code => <<'CODE' +{ + gint x, y, width, height; + + success = gimp_item_is_attached (GIMP_ITEM (drawable)); + + if (success && + gimp_drawable_mask_intersect (drawable, &x, &y, &width, &height)) + { + GimpMatrix3 matrix; + GimpInterpolationType interpolation_type = GIMP_INTERPOLATION_NONE; + + /* Assemble the transformation matrix */ + gimp_transform_matrix_perspective (x, y, width, height, + trans_info[X0], trans_info[Y0], + trans_info[X1], trans_info[Y1], + trans_info[X2], trans_info[Y2], + trans_info[X3], trans_info[Y3], + &matrix); + + if (interpolation) + interpolation_type = gimp->config->interpolation_type; + + if (progress) + gimp_progress_start (progress, _("Perspective..."), FALSE); + + /* Perspective the selection */ + success = gimp_drawable_transform_affine (drawable, context, + &matrix, GIMP_TRANSFORM_FORWARD, + interpolation_type, + interpolation, 3, + clip_result, progress); + + if (progress) + gimp_progress_end (progress); + } +} +CODE + ); +} + + sub drawable_transform_rotate_simple { $blurb = <<'BLURB'; Rotate the specified drawable about given coordinates through the specified angle. @@ -393,6 +545,78 @@ CODE ); } + +sub drawable_transform_rotate_defaults { + $blurb = <<'BLURB'; +Rotate the specified drawable about given coordinates through the specified angle. +BLURB + + $help = <<'HELP'; +This procedure is a variant of gimp_drawable_transform_rotate() which +uses no interpolation/supersampling at all, or default values +(depending on the 'interpolation' parameter). +HELP + + &pdb_misc; + + @inargs = ( + &drawable_arg, + { name => 'angle', type => 'float', + desc => 'The angle of rotation (radians)' }, + { name => 'auto_center', type => 'boolean', + desc => 'Whether to automatically rotate around the selection center' }, + { name => 'center_x', type => 'int32', + desc => 'The hor. coordinate of the center of rotation' }, + { name => 'center_y', type => 'int32', + desc => 'The vert. coordinate of the center of rotation' }, + &transform_options_defaults_args + ); + + @outargs = ( &drawable_out_arg('rotated') ); + + %invoke = ( + code => <<'CODE' +{ + gint x, y, width, height; + + success = gimp_item_is_attached (GIMP_ITEM (drawable)); + + if (success && + gimp_drawable_mask_intersect (drawable, &x, &y, &width, &height)) + { + GimpMatrix3 matrix; + GimpInterpolationType interpolation_type = GIMP_INTERPOLATION_NONE; + + /* Assemble the transformation matrix */ + if (auto_center) + gimp_transform_matrix_rotate (x, y, width, height, angle, + &matrix); + else + gimp_transform_matrix_rotate_center (center_x, center_y, angle, + &matrix); + + if (interpolation) + interpolation_type = gimp->config->interpolation_type; + + if (progress) + gimp_progress_start (progress, _("Rotating..."), FALSE); + + /* Rotate the selection */ + success = gimp_drawable_transform_affine (drawable, context, + &matrix, GIMP_TRANSFORM_FORWARD, + interpolation_type, + interpolation, 3, + clip_result, progress); + + if (progress) + gimp_progress_end (progress); + } +} +CODE + ); +} + + sub drawable_transform_scale { $blurb = 'Scale the specified drawable with extra parameters'; @@ -425,7 +649,7 @@ HELP } @inargs = (@inargs, - &transform_options_args + &transform_options_args ); @outargs = ( &drawable_out_arg('scaled') ); @@ -471,6 +695,86 @@ CODE ); } + +sub drawable_transform_scale_defaults { + $blurb = 'Scale the specified drawable with extra parameters'; + + $help = <<'HELP'; +This procedure is a variant of gimp_drawable_transform_scale() which +uses no interpolation/supersampling at all, or default values +(depending on the 'interpolation' parameter). +HELP + + &pdb_misc; + + @inargs = ( + &drawable_arg + ); + + my $pos = 0; + foreach $where (qw(upper-left lower-right)) { + foreach (qw(x y)) { + push @inargs, + { name => "$_$pos", type => 'float', + desc => "The new $_ coordinate of $where corner of newly + scaled region", + alias => "trans_info[\U$_\E$pos]", no_declare => 1 } + } + $pos++; + } + + @inargs = (@inargs, + &transform_options_defaults_args + ); + + @outargs = ( &drawable_out_arg('scaled') ); + + %invoke = ( + vars => [ 'gdouble trans_info[4]' ], + code => <<'CODE' +{ + gint x, y, width, height; + + success = (gimp_item_is_attached (GIMP_ITEM (drawable)) && + trans_info[X0] < trans_info[X1] && + trans_info[Y0] < trans_info[X1]); + + if (success && + gimp_drawable_mask_intersect (drawable, &x, &y, &width, &height)) + { + GimpMatrix3 matrix; + GimpInterpolationType interpolation_type = GIMP_INTERPOLATION_NONE; + + /* Assemble the transformation matrix */ + gimp_transform_matrix_scale (x, y, width, height, + trans_info[X0], + trans_info[Y0], + trans_info[X1] - trans_info[X0], + trans_info[Y1] - trans_info[Y0], + &matrix); + + if (interpolation) + interpolation_type = gimp->config->interpolation_type; + + if (progress) + gimp_progress_start (progress, _("Scaling..."), FALSE); + + /* Scale the selection */ + success = gimp_drawable_transform_affine (drawable, context, + &matrix, GIMP_TRANSFORM_FORWARD, + interpolation_type, + interpolation, 3, + clip_result, progress); + + if (progress) + gimp_progress_end (progress); + } +} +CODE + ); +} + + sub drawable_transform_shear { $blurb = <<'BLURB'; Shear the specified drawable about its center by the specified magnitude, with extra parameters. @@ -538,6 +842,70 @@ CODE } +sub drawable_transform_shear_defaults { + $blurb = <<'BLURB'; +Shear the specified drawable about its center by the specified magnitude, with extra parameters. +BLURB + + $help = <<'HELP'; +This procedure is a variant of gimp_drawable_transform_shear() which +uses no interpolation/supersampling at all, or default values +(depending on the 'interpolation' parameter). +HELP + + &pdb_misc; + + @inargs = ( + &drawable_arg, + { name => 'shear_type', type => &std_orientation_enum, + desc => 'Type of shear: %%desc%%' }, + { name => 'magnitude', type => 'float', + desc => 'The magnitude of the shear' }, + &transform_options_defaults_args + ); + + @outargs = ( &drawable_out_arg('sheared') ); + + %invoke = ( + code => <<'CODE' +{ + gint x, y, width, height; + + success = gimp_item_is_attached (GIMP_ITEM (drawable)); + + if (success && + gimp_drawable_mask_intersect (drawable, &x, &y, &width, &height)) + { + GimpMatrix3 matrix; + GimpInterpolationType interpolation_type = GIMP_INTERPOLATION_NONE; + + /* Assemble the transformation matrix */ + gimp_transform_matrix_shear (x, y, width, height, + shear_type, magnitude, + &matrix); + + if (interpolation) + interpolation_type = gimp->config->interpolation_type; + + if (progress) + gimp_progress_start (progress, _("Shearing..."), FALSE); + + /* Shear the selection */ + success = gimp_drawable_transform_affine (drawable, context, + &matrix, GIMP_TRANSFORM_FORWARD, + interpolation_type, + interpolation, 3, + clip_result, progress); + + if (progress) + gimp_progress_end (progress); + } +} +CODE + ); +} + + sub drawable_transform_2d { $blurb = <<'BLURB'; Transform the specified drawable in 2d, with extra parameters. @@ -617,6 +985,83 @@ CODE ); } + +sub drawable_transform_2d_defaults { + $blurb = <<'BLURB'; +Transform the specified drawable in 2d, with extra parameters. +BLURB + + $help = <<'HELP'; +This procedure is a variant of gimp_drawable_transform_2d() which +uses no interpolation/supersampling at all, or default values +(depending on the 'interpolation' parameter). +HELP + + &pdb_misc; + + @inargs = ( + &drawable_arg, + { name => 'source_x', type => 'float', + desc => 'X coordinate of the transformation center' }, + { name => 'source_y', type => 'float', + desc => 'Y coordinate of the transformation center' }, + { name => 'scale_x', type => 'float', + desc => 'Amount to scale in x direction' }, + { name => 'scale_y', type => 'float', + desc => 'Amount to scale in y direction' }, + { name => 'angle', type => 'float', + desc => 'The angle of rotation (radians)' }, + { name => 'dest_x', type => 'float', + desc => 'X coordinate of where the center goes' }, + { name => 'dest_y', type => 'float', + desc => 'Y coordinate of where the center goes' }, + &transform_options_defaults_args + ); + + @outargs = ( &drawable_out_arg('transformed') ); + + %invoke = ( + code => <<'CODE' +{ + gint x, y, width, height; + + success = gimp_item_is_attached (GIMP_ITEM (drawable)); + + if (success && + gimp_drawable_mask_intersect (drawable, &x, &y, &width, &height)) + { + GimpMatrix3 matrix; + GimpInterpolationType interpolation_type = GIMP_INTERPOLATION_NONE; + + /* Assemble the transformation matrix */ + gimp_matrix3_identity (&matrix); + gimp_matrix3_translate (&matrix, -source_x, -source_y); + gimp_matrix3_scale (&matrix, scale_x, scale_y); + gimp_matrix3_rotate (&matrix, angle); + gimp_matrix3_translate (&matrix, dest_x, dest_y); + + if (interpolation) + interpolation_type = gimp->config->interpolation_type; + + if (progress) + gimp_progress_start (progress, _("2D Transform..."), FALSE); + + /* Transform the selection */ + success = gimp_drawable_transform_affine (drawable, context, + &matrix, GIMP_TRANSFORM_FORWARD, + interpolation_type, + interpolation, 3, + clip_result, progress); + + if (progress) + gimp_progress_end (progress); + } +} +CODE + ); +} + + sub drawable_transform_matrix { $blurb = <<'BLURB'; Transform the specified drawable in 2d, with extra parameters. @@ -701,17 +1146,107 @@ CODE ); } + +sub drawable_transform_matrix_defaults { + $blurb = <<'BLURB'; +Transform the specified drawable in 2d, with extra parameters. +BLURB + + $help = <<'HELP'; +This procedure is a variant of gimp_drawable_transform_matrix() which +uses no interpolation/supersampling at all, or default values +(depending on the 'interpolation' parameter). +HELP + + &pdb_misc; + + @inargs = ( + &drawable_arg, + { name => 'coeff_0_0', type => 'float', + desc => 'coefficient (0,0) of the transformation matrix' }, + { name => 'coeff_0_1', type => 'float', + desc => 'coefficient (0,1) of the transformation matrix' }, + { name => 'coeff_0_2', type => 'float', + desc => 'coefficient (0,2) of the transformation matrix' }, + { name => 'coeff_1_0', type => 'float', + desc => 'coefficient (1,0) of the transformation matrix' }, + { name => 'coeff_1_1', type => 'float', + desc => 'coefficient (1,1) of the transformation matrix' }, + { name => 'coeff_1_2', type => 'float', + desc => 'coefficient (1,2) of the transformation matrix' }, + { name => 'coeff_2_0', type => 'float', + desc => 'coefficient (2,0) of the transformation matrix' }, + { name => 'coeff_2_1', type => 'float', + desc => 'coefficient (2,1) of the transformation matrix' }, + { name => 'coeff_2_2', type => 'float', + desc => 'coefficient (2,2) of the transformation matrix' }, + &transform_options_defaults_args + ); + + @outargs = ( &drawable_out_arg('transformed') ); + + %invoke = ( + code => <<'CODE' +{ + gint x, y, width, height; + + success = gimp_item_is_attached (GIMP_ITEM (drawable)); + + if (success && + gimp_drawable_mask_intersect (drawable, &x, &y, &width, &height)) + { + GimpMatrix3 matrix; + GimpInterpolationType interpolation_type = GIMP_INTERPOLATION_NONE; + + /* Assemble the transformation matrix */ + matrix.coeff[0][0] = coeff_0_0; + matrix.coeff[0][1] = coeff_0_1; + matrix.coeff[0][2] = coeff_0_2; + matrix.coeff[1][0] = coeff_1_0; + matrix.coeff[1][1] = coeff_1_1; + matrix.coeff[1][2] = coeff_1_2; + matrix.coeff[2][0] = coeff_2_0; + matrix.coeff[2][1] = coeff_2_1; + matrix.coeff[2][2] = coeff_2_2; + + if (interpolation) + interpolation_type = gimp->config->interpolation_type; + + if (progress) + gimp_progress_start (progress, _("2D Transform..."), FALSE); + + /* Transform the selection */ + success = gimp_drawable_transform_affine (drawable, context, + &matrix, GIMP_TRANSFORM_FORWARD, + interpolation_type, + interpolation, 3, + clip_result, progress); + + if (progress) + gimp_progress_end (progress); + } +} +CODE + ); +} + + @headers = qw("libgimpmath/gimpmath.h" "config/gimpcoreconfig.h" "core/gimp.h" "core/gimp-transform-utils.h" "core/gimpimage.h" "core/gimpdrawable.h" "core/gimpdrawable-transform.h" "core/gimpprogress.h" "gimp-intl.h"); -@procs = qw(drawable_transform_flip_simple drawable_transform_flip +@procs = qw(drawable_transform_flip_simple + drawable_transform_flip drawable_transform_flip_defaults drawable_transform_perspective - drawable_transform_rotate_simple drawable_transform_rotate - drawable_transform_scale drawable_transform_shear - drawable_transform_2d drawable_transform_matrix); + drawable_transform_perspective_defaults + drawable_transform_rotate_simple + drawable_transform_rotate drawable_transform_rotate_defaults + drawable_transform_scale drawable_transform_scale_defaults + drawable_transform_shear drawable_transform_shear_defaults + drawable_transform_2d drawable_transform_2d_defaults + drawable_transform_matrix drawable_transform_matrix_defaults); %exports = (app => [@procs], lib => [@procs]);