[gimp/goat-invasion: 184/418] app: port everything to gimp_selection_extract_buffer()



commit 37c16e08ec3f26e36663ab74cfa80901eff9b01c
Author: Michael Natterer <mitch gimp org>
Date:   Wed Mar 21 14:38:19 2012 +0100

    app: port everything to gimp_selection_extract_buffer()

 app/core/gimp-edit.c     |   34 +++++++++++++++-------------------
 app/core/gimpselection.c |   28 +++++++++++++---------------
 2 files changed, 28 insertions(+), 34 deletions(-)
---
diff --git a/app/core/gimp-edit.c b/app/core/gimp-edit.c
index 782b737..f10ca52 100644
--- a/app/core/gimp-edit.c
+++ b/app/core/gimp-edit.c
@@ -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);
-
-      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);
+      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);
 
-      return buffer;
+      return gimp_buffer;
     }
 
   return NULL;
diff --git a/app/core/gimpselection.c b/app/core/gimpselection.c
index 000556d..e30fe7b 100644
--- a/app/core/gimpselection.c
+++ b/app/core/gimpselection.c
@@ -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);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]