mirror of https://github.com/GNOME/gimp.git
app: make sure a floating selection always has its drawable's format + alpha
we were missing a conversion when pasting whole images to channels and masks.
This commit is contained in:
parent
8aa0a04854
commit
5cf3cf27fd
|
@ -330,9 +330,10 @@ gimp_edit_paste (GimpImage *image,
|
||||||
gint viewport_width,
|
gint viewport_width,
|
||||||
gint viewport_height)
|
gint viewport_height)
|
||||||
{
|
{
|
||||||
GimpLayer *layer;
|
GimpLayer *layer = NULL;
|
||||||
gint offset_x;
|
const Babl *floating_format;
|
||||||
gint offset_y;
|
gint offset_x;
|
||||||
|
gint offset_y;
|
||||||
|
|
||||||
g_return_val_if_fail (GIMP_IS_IMAGE (image), NULL);
|
g_return_val_if_fail (GIMP_IS_IMAGE (image), NULL);
|
||||||
g_return_val_if_fail (drawable == NULL || GIMP_IS_DRAWABLE (drawable), NULL);
|
g_return_val_if_fail (drawable == NULL || GIMP_IS_DRAWABLE (drawable), NULL);
|
||||||
|
@ -350,6 +351,14 @@ gimp_edit_paste (GimpImage *image,
|
||||||
paste_type = GIMP_PASTE_TYPE_NEW_LAYER;
|
paste_type = GIMP_PASTE_TYPE_NEW_LAYER;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* floating pastes always have the pasted-to drawable's format with
|
||||||
|
* alpha; if drawable == NULL, user is pasting into an empty image
|
||||||
|
*/
|
||||||
|
if (drawable)
|
||||||
|
floating_format = gimp_drawable_get_format_with_alpha (drawable);
|
||||||
|
else
|
||||||
|
floating_format = gimp_image_get_layer_format (image, TRUE);
|
||||||
|
|
||||||
if (GIMP_IS_IMAGE (paste))
|
if (GIMP_IS_IMAGE (paste))
|
||||||
{
|
{
|
||||||
GType layer_type;
|
GType layer_type;
|
||||||
|
@ -382,27 +391,33 @@ gimp_edit_paste (GimpImage *image,
|
||||||
{
|
{
|
||||||
case GIMP_PASTE_TYPE_FLOATING:
|
case GIMP_PASTE_TYPE_FLOATING:
|
||||||
case GIMP_PASTE_TYPE_FLOATING_INTO:
|
case GIMP_PASTE_TYPE_FLOATING_INTO:
|
||||||
/* when pasting as floating selection, get rid of the layer mask */
|
/* when pasting as floating selection, get rid of the layer mask,
|
||||||
|
* and make sure the layer has the right format
|
||||||
|
*/
|
||||||
if (gimp_layer_get_mask (layer))
|
if (gimp_layer_get_mask (layer))
|
||||||
gimp_layer_apply_mask (layer, GIMP_MASK_DISCARD, FALSE);
|
gimp_layer_apply_mask (layer, GIMP_MASK_DISCARD, FALSE);
|
||||||
|
|
||||||
|
if (gimp_drawable_get_format (GIMP_DRAWABLE (layer)) !=
|
||||||
|
floating_format)
|
||||||
|
{
|
||||||
|
gimp_drawable_convert_type (GIMP_DRAWABLE (layer), image,
|
||||||
|
gimp_drawable_get_base_type (drawable),
|
||||||
|
gimp_drawable_get_precision (drawable),
|
||||||
|
TRUE,
|
||||||
|
NULL,
|
||||||
|
0, 0,
|
||||||
|
FALSE, NULL);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else if (GIMP_IS_BUFFER (paste))
|
||||||
{
|
{
|
||||||
const Babl *format;
|
|
||||||
|
|
||||||
/* If drawable == NULL, user is pasting into an empty image */
|
|
||||||
if (drawable)
|
|
||||||
format = gimp_drawable_get_format_with_alpha (drawable);
|
|
||||||
else
|
|
||||||
format = gimp_image_get_layer_format (image, TRUE);
|
|
||||||
|
|
||||||
layer = gimp_layer_new_from_buffer (GIMP_BUFFER (paste), image,
|
layer = gimp_layer_new_from_buffer (GIMP_BUFFER (paste), image,
|
||||||
format,
|
floating_format,
|
||||||
_("Pasted Layer"),
|
_("Pasted Layer"),
|
||||||
GIMP_OPACITY_OPAQUE, GIMP_NORMAL_MODE);
|
GIMP_OPACITY_OPAQUE, GIMP_NORMAL_MODE);
|
||||||
}
|
}
|
||||||
|
@ -425,9 +440,9 @@ gimp_edit_paste (GimpImage *image,
|
||||||
switch (paste_type)
|
switch (paste_type)
|
||||||
{
|
{
|
||||||
case GIMP_PASTE_TYPE_FLOATING:
|
case GIMP_PASTE_TYPE_FLOATING:
|
||||||
/* If there is a selection mask clear it--
|
/* if there is a selection mask clear it - this might not
|
||||||
* this might not always be desired, but in general,
|
* always be desired, but in general, it seems like the correct
|
||||||
* it seems like the correct behavior.
|
* behavior
|
||||||
*/
|
*/
|
||||||
if (! gimp_channel_is_empty (gimp_image_get_mask (image)))
|
if (! gimp_channel_is_empty (gimp_image_get_mask (image)))
|
||||||
gimp_channel_clear (gimp_image_get_mask (image), NULL, TRUE);
|
gimp_channel_clear (gimp_image_get_mask (image), NULL, TRUE);
|
||||||
|
|
Loading…
Reference in New Issue