Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
GNOME
GIMP
Commits
ba5c4233
Commit
ba5c4233
authored
Jan 24, 2023
by
Jehan
Browse files
Issue
#8924
: Paste as new image uses the full canvas instead of just…
… the copied selection.
parent
2e30a92c
Pipeline
#484118
passed with stage
in 4 minutes and 9 seconds
Changes
6
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
app/actions/buffers-commands.c
View file @
ba5c4233
...
...
@@ -123,7 +123,8 @@ buffers_paste_as_new_image_cmd_callback (GimpAction *action,
GimpImage
*
new_image
;
new_image
=
gimp_edit_paste_as_new_image
(
context
->
gimp
,
GIMP_OBJECT
(
buffer
));
GIMP_OBJECT
(
buffer
),
context
);
gimp_create_display
(
context
->
gimp
,
new_image
,
GIMP_UNIT_PIXEL
,
1
.
0
,
G_OBJECT
(
gimp_widget_get_monitor
(
widget
)));
...
...
app/actions/edit-commands.c
View file @
ba5c4233
...
...
@@ -426,7 +426,8 @@ edit_paste_as_new_image_cmd_callback (GimpAction *action,
if
(
paste
)
{
image
=
gimp_edit_paste_as_new_image
(
gimp
,
paste
);
image
=
gimp_edit_paste_as_new_image
(
gimp
,
paste
,
action_data_get_context
(
data
));
g_object_unref
(
paste
);
}
...
...
app/core/gimp-edit.c
View file @
ba5c4233
...
...
@@ -36,6 +36,7 @@
#include
"gimpimage-duplicate.h"
#include
"gimpimage-merge.h"
#include
"gimpimage-new.h"
#include
"gimpimage-resize.h"
#include
"gimpimage-undo.h"
#include
"gimplayer-floating-selection.h"
#include
"gimplayer-new.h"
...
...
@@ -251,6 +252,24 @@ gimp_edit_copy (GimpImage *image,
item_x
-
selection_bounds
.
x
,
item_y
-
selection_bounds
.
y
);
}
g_list_free
(
all_items
);
/* We need to keep the image size as-is, because even after cropping
* layers to selection, their offset stay important for in-place paste
* variants. Yet we also need to store the dimensions where we'd have
* cropped the image for the "Paste as New Image" action.
*/
g_object_set_data
(
G_OBJECT
(
clip_image
),
"gimp-edit-new-image-x"
,
GINT_TO_POINTER
(
selection_bounds
.
x
));
g_object_set_data
(
G_OBJECT
(
clip_image
),
"gimp-edit-new-image-y"
,
GINT_TO_POINTER
(
selection_bounds
.
y
));
g_object_set_data
(
G_OBJECT
(
clip_image
),
"gimp-edit-new-image-width"
,
GINT_TO_POINTER
(
selection_bounds
.
width
));
g_object_set_data
(
G_OBJECT
(
clip_image
),
"gimp-edit-new-image-height"
,
GINT_TO_POINTER
(
selection_bounds
.
height
));
}
/* Remove selection from the clipboard image. */
gimp_channel_clear
(
clip_selection
,
NULL
,
FALSE
);
...
...
@@ -914,8 +933,9 @@ gimp_edit_paste (GimpImage *image,
}
GimpImage
*
gimp_edit_paste_as_new_image
(
Gimp
*
gimp
,
GimpObject
*
paste
)
gimp_edit_paste_as_new_image
(
Gimp
*
gimp
,
GimpObject
*
paste
,
GimpContext
*
context
)
{
GimpImage
*
image
=
NULL
;
...
...
@@ -924,7 +944,29 @@ gimp_edit_paste_as_new_image (Gimp *gimp,
if
(
GIMP_IS_IMAGE
(
paste
))
{
gint
offset_x
;
gint
offset_y
;
gint
new_width
;
gint
new_height
;
offset_x
=
GPOINTER_TO_INT
(
g_object_get_data
(
G_OBJECT
(
paste
),
"gimp-edit-new-image-x"
));
offset_y
=
GPOINTER_TO_INT
(
g_object_get_data
(
G_OBJECT
(
paste
),
"gimp-edit-new-image-y"
));
new_width
=
GPOINTER_TO_INT
(
g_object_get_data
(
G_OBJECT
(
paste
),
"gimp-edit-new-image-width"
));
new_height
=
GPOINTER_TO_INT
(
g_object_get_data
(
G_OBJECT
(
paste
),
"gimp-edit-new-image-height"
));
image
=
gimp_image_duplicate
(
GIMP_IMAGE
(
paste
));
if
(
new_width
>
0
&&
new_height
>
0
)
{
gimp_image_undo_disable
(
image
);
gimp_image_resize
(
image
,
context
,
new_width
,
new_height
,
-
offset_x
,
-
offset_y
,
NULL
);
gimp_image_undo_enable
(
image
);
}
}
else
if
(
GIMP_IS_BUFFER
(
paste
))
{
...
...
app/core/gimp-edit.h
View file @
ba5c4233
...
...
@@ -42,7 +42,8 @@ GList * gimp_edit_paste (GimpImage *image,
gint
viewport_width
,
gint
viewport_height
);
GimpImage
*
gimp_edit_paste_as_new_image
(
Gimp
*
gimp
,
GimpObject
*
paste
);
GimpObject
*
paste
,
GimpContext
*
context
);
const
gchar
*
gimp_edit_named_cut
(
GimpImage
*
image
,
const
gchar
*
name
,
...
...
app/pdb/edit-cmds.c
View file @
ba5c4233
...
...
@@ -325,7 +325,7 @@ edit_paste_as_new_image_invoker (GimpProcedure *procedure,
if
(
paste
)
{
image
=
gimp_edit_paste_as_new_image
(
gimp
,
paste
);
image
=
gimp_edit_paste_as_new_image
(
gimp
,
paste
,
context
);
if
(
!
image
)
success
=
FALSE
;
...
...
@@ -641,7 +641,7 @@ edit_named_paste_as_new_image_invoker (GimpProcedure *procedure,
if
(
buffer
)
{
image
=
gimp_edit_paste_as_new_image
(
gimp
,
GIMP_OBJECT
(
buffer
));
image
=
gimp_edit_paste_as_new_image
(
gimp
,
GIMP_OBJECT
(
buffer
)
,
context
);
if
(
!
image
)
success
=
FALSE
;
...
...
pdb/groups/edit.pdb
View file @
ba5c4233
...
...
@@ -332,7 +332,7 @@ HELP
if (paste)
{
image = gimp_edit_paste_as_new_image (gimp, paste);
image = gimp_edit_paste_as_new_image (gimp, paste
, context
);
if (! image)
success = FALSE;
...
...
@@ -660,7 +660,7 @@ HELP
if (buffer)
{
image = gimp_edit_paste_as_new_image (gimp, GIMP_OBJECT (buffer));
image = gimp_edit_paste_as_new_image (gimp, GIMP_OBJECT (buffer)
, context
);
if (! image)
success = FALSE;
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment