diff --git a/app/actions/image-commands.c b/app/actions/image-commands.c index fcb3f2bf6b..675aadeafd 100644 --- a/app/actions/image-commands.c +++ b/app/actions/image-commands.c @@ -529,13 +529,12 @@ image_crop_to_selection_cmd_callback (GtkAction *action, { GimpImage *image; GtkWidget *widget; - gint x, y; - gint width, height; + gint x, y, w, h; return_if_no_image (image, data); return_if_no_widget (widget, data); if (! gimp_item_bounds (GIMP_ITEM (gimp_image_get_mask (image)), - &x, &y, &width, &height)) + &x, &y, &w, &h)) { gimp_message_literal (image->gimp, G_OBJECT (widget), GIMP_MESSAGE_WARNING, @@ -544,7 +543,7 @@ image_crop_to_selection_cmd_callback (GtkAction *action, } gimp_image_crop (image, action_data_get_context (data), - x, y, x + width, y + height, TRUE); + x, y, w, h, TRUE); gimp_image_flush (image); } @@ -566,7 +565,7 @@ image_crop_to_content_cmd_callback (GtkAction *action, { case GIMP_AUTO_SHRINK_SHRINK: gimp_image_crop (image, action_data_get_context (data), - x1, y1, x2, y2, TRUE); + x1, y1, x2 - x1, y2 - y1, TRUE); gimp_image_flush (image); break; diff --git a/app/core/gimpimage-crop.c b/app/core/gimpimage-crop.c index 4c14386c5b..48537d04ed 100644 --- a/app/core/gimpimage-crop.c +++ b/app/core/gimpimage-crop.c @@ -42,25 +42,22 @@ void gimp_image_crop (GimpImage *image, GimpContext *context, - gint x1, - gint y1, - gint x2, - gint y2, + gint x, + gint y, + gint width, + gint height, gboolean crop_layers) { GList *list; - gint width, height; - gint previous_width, previous_height; + gint previous_width; + gint previous_height; g_return_if_fail (GIMP_IS_IMAGE (image)); g_return_if_fail (GIMP_IS_CONTEXT (context)); - previous_width = gimp_image_get_width (image); + previous_width = gimp_image_get_width (image); previous_height = gimp_image_get_height (image); - width = x2 - x1; - height = y2 - y1; - /* Make sure new width and height are non-zero */ if (width < 1 || height < 1) return; @@ -78,7 +75,7 @@ gimp_image_crop (GimpImage *image, /* Push the image size to the stack */ gimp_image_undo_push_image_size (image, NULL, - x1, y1, width, height); + x, y, width, height); /* Set the new width and height */ g_object_set (image, @@ -93,7 +90,7 @@ gimp_image_crop (GimpImage *image, { GimpItem *item = list->data; - gimp_item_resize (item, context, width, height, -x1, -y1); + gimp_item_resize (item, context, width, height, -x, -y); } /* Resize all vectors */ @@ -103,12 +100,12 @@ gimp_image_crop (GimpImage *image, { GimpItem *item = list->data; - gimp_item_resize (item, context, width, height, -x1, -y1); + gimp_item_resize (item, context, width, height, -x, -y); } /* Don't forget the selection mask! */ gimp_item_resize (GIMP_ITEM (gimp_image_get_mask (image)), context, - width, height, -x1, -y1); + width, height, -x, -y); /* crop all layers */ list = gimp_image_get_layer_iter (image); @@ -119,7 +116,7 @@ gimp_image_crop (GimpImage *image, list = g_list_next (list); - gimp_item_translate (item, -x1, -y1, TRUE); + gimp_item_translate (item, -x, -y, TRUE); if (crop_layers) { @@ -166,17 +163,17 @@ gimp_image_crop (GimpImage *image, switch (gimp_guide_get_orientation (guide)) { case GIMP_ORIENTATION_HORIZONTAL: - if ((position < y1) || (position > y2)) + if ((position < y) || (position > (y + height))) remove_guide = TRUE; else - position -= y1; + position -= y; break; case GIMP_ORIENTATION_VERTICAL: - if ((position < x1) || (position > x2)) + if ((position < x) || (position > (x + width))) remove_guide = TRUE; else - position -= x1; + position -= x; break; default: @@ -201,12 +198,12 @@ gimp_image_crop (GimpImage *image, list = g_list_next (list); - new_y -= y1; - if ((sample_point->y < y1) || (sample_point->y > y2)) + new_y -= y; + if ((sample_point->y < y) || (sample_point->y > (y + height))) remove_sample_point = TRUE; - new_x -= x1; - if ((sample_point->x < x1) || (sample_point->x > x2)) + new_x -= x; + if ((sample_point->x < x) || (sample_point->x > (x + width))) remove_sample_point = TRUE; if (remove_sample_point) @@ -219,7 +216,7 @@ gimp_image_crop (GimpImage *image, gimp_image_undo_group_end (image); gimp_image_size_changed_detailed (image, - -x1, -y1, + -x, -y, previous_width, previous_height); g_object_thaw_notify (G_OBJECT (image)); diff --git a/app/core/gimpimage-crop.h b/app/core/gimpimage-crop.h index d437cf2356..33094e3614 100644 --- a/app/core/gimpimage-crop.h +++ b/app/core/gimpimage-crop.h @@ -21,10 +21,10 @@ void gimp_image_crop (GimpImage *image, GimpContext *context, - gint x1, - gint y1, - gint x2, - gint y2, + gint x, + gint y, + gint width, + gint height, gboolean crop_layers); diff --git a/app/pdb/image-transform-cmds.c b/app/pdb/image-transform-cmds.c index 50e8913fea..1f685d1cb5 100644 --- a/app/pdb/image-transform-cmds.c +++ b/app/pdb/image-transform-cmds.c @@ -197,7 +197,7 @@ image_crop_invoker (GimpProcedure *procedure, success = FALSE; else gimp_image_crop (image, context, - offx, offy, offx + new_width, offy + new_height, + offx, offy, new_width, new_height, TRUE); } diff --git a/app/pdb/plug-in-compat-cmds.c b/app/pdb/plug-in-compat-cmds.c index 8a50f954a8..15346f6dc9 100644 --- a/app/pdb/plug-in-compat-cmds.c +++ b/app/pdb/plug-in-compat-cmds.c @@ -611,7 +611,7 @@ plug_in_autocrop_invoker (GimpProcedure *procedure, } gimp_image_crop (image, context, - x1, y1, x2, y2, TRUE); + x1, y1, x2 - x1, y2 - y1, TRUE); gimp_image_undo_group_end (image); } diff --git a/app/tools/gimpcroptool.c b/app/tools/gimpcroptool.c index 6bc595bc4c..b2c681489c 100644 --- a/app/tools/gimpcroptool.c +++ b/app/tools/gimpcroptool.c @@ -337,7 +337,7 @@ gimp_crop_tool_execute (GimpRectangleTool *rectangle, else { gimp_image_crop (image, GIMP_CONTEXT (options), - x, y, w + x, h + y, + x, y, w, h, TRUE); } diff --git a/tools/pdbgen/pdb/image_transform.pdb b/tools/pdbgen/pdb/image_transform.pdb index cad7c06167..f2590890d8 100644 --- a/tools/pdbgen/pdb/image_transform.pdb +++ b/tools/pdbgen/pdb/image_transform.pdb @@ -195,7 +195,7 @@ HELP success = FALSE; else gimp_image_crop (image, context, - offx, offy, offx + new_width, offy + new_height, + offx, offy, new_width, new_height, TRUE); } CODE diff --git a/tools/pdbgen/pdb/plug_in_compat.pdb b/tools/pdbgen/pdb/plug_in_compat.pdb index 3e3ecf91dc..2034bb8282 100644 --- a/tools/pdbgen/pdb/plug_in_compat.pdb +++ b/tools/pdbgen/pdb/plug_in_compat.pdb @@ -309,7 +309,7 @@ HELP } gimp_image_crop (image, context, - x1, y1, x2, y2, TRUE); + x1, y1, x2 - x1, y2 - y1, TRUE); gimp_image_undo_group_end (image); }