Skip to content

Commit dbe5bc7

Browse files
committed
core: Fix Alpha to Selection on single no-alpha layer
Resolves #14392 When using Alpha to Selection on a single layer with no transparency, we were not cropping the selection channel from the image size to the the layer size. As a result, we were essentially performing Select All instead of only selecting the area of the layer itself. This patch refactors gimp_channel_combine_items () in its single layer check, to create a mask for single layers with no alpha that is the size of the layer. It's then used to crop the image channel the same way the alpha channel does for layers that have transparency.
1 parent d54e274 commit dbe5bc7

File tree

1 file changed

+14
-10
lines changed

1 file changed

+14
-10
lines changed

app/core/gimpchannel-combine.c

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -556,24 +556,28 @@ gimp_channel_combine_items (GimpChannel *mask,
556556

557557
if (g_list_length (layers) == 1)
558558
{
559+
GimpChannel *alpha;
560+
gint offset_x;
561+
gint offset_y;
562+
559563
if (gimp_drawable_has_alpha (layers->data))
560564
{
561-
GimpChannel *alpha;
562-
gint offset_x;
563-
gint offset_y;
564-
565565
alpha = gimp_channel_new_from_alpha (image,
566566
layers->data, NULL, NULL);
567-
gimp_item_get_offset (layers->data, &offset_x, &offset_y);
568-
gimp_channel_combine_mask (channel, alpha,
569-
GIMP_CHANNEL_OP_REPLACE,
570-
offset_x, offset_y);
571-
g_object_unref (alpha);
572567
}
573568
else
574569
{
575-
gimp_channel_all (channel, FALSE);
570+
alpha = gimp_channel_new (image,
571+
gimp_item_get_width (layers->data),
572+
gimp_item_get_height (layers->data),
573+
NULL, NULL);
574+
gimp_channel_all (alpha, FALSE);
576575
}
576+
gimp_item_get_offset (layers->data, &offset_x, &offset_y);
577+
gimp_channel_combine_mask (channel, alpha,
578+
GIMP_CHANNEL_OP_REPLACE,
579+
offset_x, offset_y);
580+
g_object_unref (alpha);
577581
}
578582
}
579583

0 commit comments

Comments
 (0)