app, pdb: fix implementation of gimp_image_autocrop_selected_layers()…

… taking into account drawable's offsets.
This commit is contained in:
Jehan 2025-02-09 18:50:19 +01:00
parent 3c21b768c5
commit d7b6647647
2 changed files with 20 additions and 2 deletions

View file

@ -135,6 +135,10 @@ image_autocrop_selected_layers_invoker (GimpProcedure *procedure,
if (layers)
{
gint off_x, off_y;
gimp_item_get_offset (GIMP_ITEM (drawable), &off_x, &off_y);
switch (gimp_pickable_auto_shrink (GIMP_PICKABLE (drawable),
0, 0,
gimp_item_get_width (GIMP_ITEM (drawable)),
@ -146,9 +150,14 @@ image_autocrop_selected_layers_invoker (GimpProcedure *procedure,
_("Autocrop layer"));
for (iter = layers; iter; iter = iter->next)
{
gint layer_off_x, layer_off_y;
gimp_item_get_offset (GIMP_ITEM (iter->data), &layer_off_x, &layer_off_y);
gimp_item_resize (GIMP_ITEM (iter->data),
context, GIMP_FILL_TRANSPARENT,
width, height, -x, -y);
width, height, layer_off_x - (off_x + x), layer_off_y - (off_y + y));
}
gimp_image_undo_group_end (image);
break;

View file

@ -119,6 +119,10 @@ HELP
if (layers)
{
gint off_x, off_y;
gimp_item_get_offset (GIMP_ITEM (drawable), &off_x, &off_y);
switch (gimp_pickable_auto_shrink (GIMP_PICKABLE (drawable),
0, 0,
gimp_item_get_width (GIMP_ITEM (drawable)),
@ -130,9 +134,14 @@ HELP
_("Autocrop layer"));
for (iter = layers; iter; iter = iter->next)
{
gint layer_off_x, layer_off_y;
gimp_item_get_offset (GIMP_ITEM (iter->data), &layer_off_x, &layer_off_y);
gimp_item_resize (GIMP_ITEM (iter->data),
context, GIMP_FILL_TRANSPARENT,
width, height, -x, -y);
width, height, layer_off_x - (off_x + x), layer_off_y - (off_y + y));
}
gimp_image_undo_group_end (image);
break;