app: change gimp_image_crop() to use x, y, width, height
This commit is contained in:
@ -529,13 +529,12 @@ image_crop_to_selection_cmd_callback (GtkAction *action,
|
|||||||
{
|
{
|
||||||
GimpImage *image;
|
GimpImage *image;
|
||||||
GtkWidget *widget;
|
GtkWidget *widget;
|
||||||
gint x, y;
|
gint x, y, w, h;
|
||||||
gint width, height;
|
|
||||||
return_if_no_image (image, data);
|
return_if_no_image (image, data);
|
||||||
return_if_no_widget (widget, data);
|
return_if_no_widget (widget, data);
|
||||||
|
|
||||||
if (! gimp_item_bounds (GIMP_ITEM (gimp_image_get_mask (image)),
|
if (! gimp_item_bounds (GIMP_ITEM (gimp_image_get_mask (image)),
|
||||||
&x, &y, &width, &height))
|
&x, &y, &w, &h))
|
||||||
{
|
{
|
||||||
gimp_message_literal (image->gimp,
|
gimp_message_literal (image->gimp,
|
||||||
G_OBJECT (widget), GIMP_MESSAGE_WARNING,
|
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),
|
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);
|
gimp_image_flush (image);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -566,7 +565,7 @@ image_crop_to_content_cmd_callback (GtkAction *action,
|
|||||||
{
|
{
|
||||||
case GIMP_AUTO_SHRINK_SHRINK:
|
case GIMP_AUTO_SHRINK_SHRINK:
|
||||||
gimp_image_crop (image, action_data_get_context (data),
|
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);
|
gimp_image_flush (image);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|||||||
@ -42,25 +42,22 @@
|
|||||||
void
|
void
|
||||||
gimp_image_crop (GimpImage *image,
|
gimp_image_crop (GimpImage *image,
|
||||||
GimpContext *context,
|
GimpContext *context,
|
||||||
gint x1,
|
gint x,
|
||||||
gint y1,
|
gint y,
|
||||||
gint x2,
|
gint width,
|
||||||
gint y2,
|
gint height,
|
||||||
gboolean crop_layers)
|
gboolean crop_layers)
|
||||||
{
|
{
|
||||||
GList *list;
|
GList *list;
|
||||||
gint width, height;
|
gint previous_width;
|
||||||
gint previous_width, previous_height;
|
gint previous_height;
|
||||||
|
|
||||||
g_return_if_fail (GIMP_IS_IMAGE (image));
|
g_return_if_fail (GIMP_IS_IMAGE (image));
|
||||||
g_return_if_fail (GIMP_IS_CONTEXT (context));
|
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);
|
previous_height = gimp_image_get_height (image);
|
||||||
|
|
||||||
width = x2 - x1;
|
|
||||||
height = y2 - y1;
|
|
||||||
|
|
||||||
/* Make sure new width and height are non-zero */
|
/* Make sure new width and height are non-zero */
|
||||||
if (width < 1 || height < 1)
|
if (width < 1 || height < 1)
|
||||||
return;
|
return;
|
||||||
@ -78,7 +75,7 @@ gimp_image_crop (GimpImage *image,
|
|||||||
|
|
||||||
/* Push the image size to the stack */
|
/* Push the image size to the stack */
|
||||||
gimp_image_undo_push_image_size (image, NULL,
|
gimp_image_undo_push_image_size (image, NULL,
|
||||||
x1, y1, width, height);
|
x, y, width, height);
|
||||||
|
|
||||||
/* Set the new width and height */
|
/* Set the new width and height */
|
||||||
g_object_set (image,
|
g_object_set (image,
|
||||||
@ -93,7 +90,7 @@ gimp_image_crop (GimpImage *image,
|
|||||||
{
|
{
|
||||||
GimpItem *item = list->data;
|
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 */
|
/* Resize all vectors */
|
||||||
@ -103,12 +100,12 @@ gimp_image_crop (GimpImage *image,
|
|||||||
{
|
{
|
||||||
GimpItem *item = list->data;
|
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! */
|
/* Don't forget the selection mask! */
|
||||||
gimp_item_resize (GIMP_ITEM (gimp_image_get_mask (image)), context,
|
gimp_item_resize (GIMP_ITEM (gimp_image_get_mask (image)), context,
|
||||||
width, height, -x1, -y1);
|
width, height, -x, -y);
|
||||||
|
|
||||||
/* crop all layers */
|
/* crop all layers */
|
||||||
list = gimp_image_get_layer_iter (image);
|
list = gimp_image_get_layer_iter (image);
|
||||||
@ -119,7 +116,7 @@ gimp_image_crop (GimpImage *image,
|
|||||||
|
|
||||||
list = g_list_next (list);
|
list = g_list_next (list);
|
||||||
|
|
||||||
gimp_item_translate (item, -x1, -y1, TRUE);
|
gimp_item_translate (item, -x, -y, TRUE);
|
||||||
|
|
||||||
if (crop_layers)
|
if (crop_layers)
|
||||||
{
|
{
|
||||||
@ -166,17 +163,17 @@ gimp_image_crop (GimpImage *image,
|
|||||||
switch (gimp_guide_get_orientation (guide))
|
switch (gimp_guide_get_orientation (guide))
|
||||||
{
|
{
|
||||||
case GIMP_ORIENTATION_HORIZONTAL:
|
case GIMP_ORIENTATION_HORIZONTAL:
|
||||||
if ((position < y1) || (position > y2))
|
if ((position < y) || (position > (y + height)))
|
||||||
remove_guide = TRUE;
|
remove_guide = TRUE;
|
||||||
else
|
else
|
||||||
position -= y1;
|
position -= y;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case GIMP_ORIENTATION_VERTICAL:
|
case GIMP_ORIENTATION_VERTICAL:
|
||||||
if ((position < x1) || (position > x2))
|
if ((position < x) || (position > (x + width)))
|
||||||
remove_guide = TRUE;
|
remove_guide = TRUE;
|
||||||
else
|
else
|
||||||
position -= x1;
|
position -= x;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@ -201,12 +198,12 @@ gimp_image_crop (GimpImage *image,
|
|||||||
|
|
||||||
list = g_list_next (list);
|
list = g_list_next (list);
|
||||||
|
|
||||||
new_y -= y1;
|
new_y -= y;
|
||||||
if ((sample_point->y < y1) || (sample_point->y > y2))
|
if ((sample_point->y < y) || (sample_point->y > (y + height)))
|
||||||
remove_sample_point = TRUE;
|
remove_sample_point = TRUE;
|
||||||
|
|
||||||
new_x -= x1;
|
new_x -= x;
|
||||||
if ((sample_point->x < x1) || (sample_point->x > x2))
|
if ((sample_point->x < x) || (sample_point->x > (x + width)))
|
||||||
remove_sample_point = TRUE;
|
remove_sample_point = TRUE;
|
||||||
|
|
||||||
if (remove_sample_point)
|
if (remove_sample_point)
|
||||||
@ -219,7 +216,7 @@ gimp_image_crop (GimpImage *image,
|
|||||||
gimp_image_undo_group_end (image);
|
gimp_image_undo_group_end (image);
|
||||||
|
|
||||||
gimp_image_size_changed_detailed (image,
|
gimp_image_size_changed_detailed (image,
|
||||||
-x1, -y1,
|
-x, -y,
|
||||||
previous_width, previous_height);
|
previous_width, previous_height);
|
||||||
|
|
||||||
g_object_thaw_notify (G_OBJECT (image));
|
g_object_thaw_notify (G_OBJECT (image));
|
||||||
|
|||||||
@ -21,10 +21,10 @@
|
|||||||
|
|
||||||
void gimp_image_crop (GimpImage *image,
|
void gimp_image_crop (GimpImage *image,
|
||||||
GimpContext *context,
|
GimpContext *context,
|
||||||
gint x1,
|
gint x,
|
||||||
gint y1,
|
gint y,
|
||||||
gint x2,
|
gint width,
|
||||||
gint y2,
|
gint height,
|
||||||
gboolean crop_layers);
|
gboolean crop_layers);
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -197,7 +197,7 @@ image_crop_invoker (GimpProcedure *procedure,
|
|||||||
success = FALSE;
|
success = FALSE;
|
||||||
else
|
else
|
||||||
gimp_image_crop (image, context,
|
gimp_image_crop (image, context,
|
||||||
offx, offy, offx + new_width, offy + new_height,
|
offx, offy, new_width, new_height,
|
||||||
TRUE);
|
TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -611,7 +611,7 @@ plug_in_autocrop_invoker (GimpProcedure *procedure,
|
|||||||
}
|
}
|
||||||
|
|
||||||
gimp_image_crop (image, context,
|
gimp_image_crop (image, context,
|
||||||
x1, y1, x2, y2, TRUE);
|
x1, y1, x2 - x1, y2 - y1, TRUE);
|
||||||
|
|
||||||
gimp_image_undo_group_end (image);
|
gimp_image_undo_group_end (image);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -337,7 +337,7 @@ gimp_crop_tool_execute (GimpRectangleTool *rectangle,
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
gimp_image_crop (image, GIMP_CONTEXT (options),
|
gimp_image_crop (image, GIMP_CONTEXT (options),
|
||||||
x, y, w + x, h + y,
|
x, y, w, h,
|
||||||
TRUE);
|
TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -195,7 +195,7 @@ HELP
|
|||||||
success = FALSE;
|
success = FALSE;
|
||||||
else
|
else
|
||||||
gimp_image_crop (image, context,
|
gimp_image_crop (image, context,
|
||||||
offx, offy, offx + new_width, offy + new_height,
|
offx, offy, new_width, new_height,
|
||||||
TRUE);
|
TRUE);
|
||||||
}
|
}
|
||||||
CODE
|
CODE
|
||||||
|
|||||||
@ -309,7 +309,7 @@ HELP
|
|||||||
}
|
}
|
||||||
|
|
||||||
gimp_image_crop (image, context,
|
gimp_image_crop (image, context,
|
||||||
x1, y1, x2, y2, TRUE);
|
x1, y1, x2 - x1, y2 - y1, TRUE);
|
||||||
|
|
||||||
gimp_image_undo_group_end (image);
|
gimp_image_undo_group_end (image);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user