mirror of https://github.com/GNOME/gimp.git
app: port everything to gimp_selection_extract_buffer()
This commit is contained in:
parent
525a405270
commit
c6daba8b5d
|
@ -577,37 +577,33 @@ gimp_edit_extract (GimpImage *image,
|
|||
gboolean cut_pixels,
|
||||
GError **error)
|
||||
{
|
||||
TileManager *tiles;
|
||||
const Babl *format;
|
||||
gint offset_x;
|
||||
gint offset_y;
|
||||
GeglBuffer *buffer;
|
||||
gint offset_x;
|
||||
gint offset_y;
|
||||
|
||||
if (cut_pixels)
|
||||
gimp_image_undo_group_start (image, GIMP_UNDO_GROUP_EDIT_CUT, C_("undo-type", "Cut"));
|
||||
|
||||
/* Cut/copy the mask portion from the image */
|
||||
tiles = gimp_selection_extract (GIMP_SELECTION (gimp_image_get_mask (image)),
|
||||
pickable, context,
|
||||
cut_pixels, FALSE, FALSE,
|
||||
&format, &offset_x, &offset_y, error);
|
||||
buffer = gimp_selection_extract_buffer (GIMP_SELECTION (gimp_image_get_mask (image)),
|
||||
pickable, context,
|
||||
cut_pixels, FALSE, FALSE,
|
||||
&offset_x, &offset_y, error);
|
||||
|
||||
if (cut_pixels)
|
||||
gimp_image_undo_group_end (image);
|
||||
|
||||
if (tiles)
|
||||
if (buffer)
|
||||
{
|
||||
GeglBuffer *temp;
|
||||
GimpBuffer *buffer;
|
||||
GimpBuffer *gimp_buffer;
|
||||
const Babl *format = gegl_buffer_get_format (buffer);
|
||||
|
||||
temp = gimp_tile_manager_create_buffer (tiles, format);
|
||||
tile_manager_unref (tiles);
|
||||
gimp_buffer = gimp_buffer_new (buffer, _("Global Buffer"),
|
||||
GIMP_IMAGE_TYPE_FROM_BYTES (babl_format_get_bytes_per_pixel (format)),
|
||||
offset_x, offset_y, FALSE);
|
||||
g_object_unref (buffer);
|
||||
|
||||
buffer = gimp_buffer_new (temp, _("Global Buffer"),
|
||||
GIMP_IMAGE_TYPE_FROM_BYTES (tile_manager_bpp (tiles)),
|
||||
offset_x, offset_y, FALSE);
|
||||
g_object_unref (temp);
|
||||
|
||||
return buffer;
|
||||
return gimp_buffer;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
|
|
|
@ -825,12 +825,11 @@ gimp_selection_float (GimpSelection *selection,
|
|||
gint off_y,
|
||||
GError **error)
|
||||
{
|
||||
GimpImage *image;
|
||||
GimpLayer *layer;
|
||||
TileManager *tiles;
|
||||
const Babl *format;
|
||||
gint x1, y1;
|
||||
gint x2, y2;
|
||||
GimpImage *image;
|
||||
GimpLayer *layer;
|
||||
GeglBuffer *buffer;
|
||||
gint x1, y1;
|
||||
gint x2, y2;
|
||||
|
||||
g_return_val_if_fail (GIMP_IS_SELECTION (selection), NULL);
|
||||
g_return_val_if_fail (GIMP_IS_DRAWABLE (drawable), NULL);
|
||||
|
@ -855,9 +854,9 @@ gimp_selection_float (GimpSelection *selection,
|
|||
C_("undo-type", "Float Selection"));
|
||||
|
||||
/* Cut or copy the selected region */
|
||||
tiles = gimp_selection_extract (selection, GIMP_PICKABLE (drawable), context,
|
||||
cut_image, FALSE, TRUE,
|
||||
&format, &x1, &y1, NULL);
|
||||
buffer = gimp_selection_extract_buffer (selection, GIMP_PICKABLE (drawable), context,
|
||||
cut_image, FALSE, TRUE,
|
||||
&x1, &y1, NULL);
|
||||
|
||||
/* Clear the selection */
|
||||
gimp_channel_clear (GIMP_CHANNEL (selection), NULL, TRUE);
|
||||
|
@ -866,17 +865,16 @@ gimp_selection_float (GimpSelection *selection,
|
|||
* because it may be different from the image's type if we cut from
|
||||
* a channel or layer mask
|
||||
*/
|
||||
layer = gimp_layer_new_from_tiles (tiles, format,
|
||||
image,
|
||||
gimp_drawable_type_with_alpha (drawable),
|
||||
_("Floated Layer"),
|
||||
GIMP_OPACITY_OPAQUE, GIMP_NORMAL_MODE);
|
||||
layer = gimp_layer_new_from_buffer (buffer, image,
|
||||
gimp_drawable_type_with_alpha (drawable),
|
||||
_("Floated Layer"),
|
||||
GIMP_OPACITY_OPAQUE, GIMP_NORMAL_MODE);
|
||||
|
||||
/* Set the offsets */
|
||||
gimp_item_set_offset (GIMP_ITEM (layer), x1 + off_x, y1 + off_y);
|
||||
|
||||
/* Free the temp buffer */
|
||||
tile_manager_unref (tiles);
|
||||
g_object_unref (buffer);
|
||||
|
||||
/* Add the floating layer to the image */
|
||||
floating_sel_attach (layer, drawable);
|
||||
|
|
Loading…
Reference in New Issue