[gimp/goat-invasion] app: add gimp_selection_extract_buffer ()



commit 917b0e117e02cbeb95287c13896e4ebbbd6ff202
Author: Michael Natterer <mitch gimp org>
Date:   Wed Mar 21 14:27:07 2012 +0100

    app: add gimp_selection_extract_buffer ()

 app/core/gimpselection.c |   35 +++++++++++++++++++++++++++++++++++
 app/core/gimpselection.h |    9 +++++++++
 2 files changed, 44 insertions(+), 0 deletions(-)
---
diff --git a/app/core/gimpselection.c b/app/core/gimpselection.c
index 71e2b4d..6688c67 100644
--- a/app/core/gimpselection.c
+++ b/app/core/gimpselection.c
@@ -614,6 +614,41 @@ gimp_selection_save (GimpSelection *selection)
   return new_channel;
 }
 
+GeglBuffer *
+gimp_selection_extract_buffer (GimpSelection *selection,
+                               GimpPickable  *pickable,
+                               GimpContext   *context,
+                               gboolean       cut_image,
+                               gboolean       keep_indexed,
+                               gboolean       add_alpha,
+                               gint          *offset_x,
+                               gint          *offset_y,
+                               GError       **error)
+{
+  TileManager *tiles;
+  const Babl  *format;
+
+  tiles = gimp_selection_extract (selection, pickable, context,
+                                  cut_image, keep_indexed, add_alpha,
+                                  &format,
+                                  offset_x, offset_y, error);
+
+  if (tiles)
+    {
+      GeglBuffer *buffer;
+
+      buffer = gimp_gegl_buffer_new (GIMP_GEGL_RECT (0, 0,
+                                                     tile_manager_width (tiles),
+                                                     tile_manager_height (tiles)),
+                                     format);
+      tile_manager_unref (tiles);
+
+      return buffer;
+    }
+
+  return NULL;
+}
+
 TileManager *
 gimp_selection_extract (GimpSelection *selection,
                         GimpPickable  *pickable,
diff --git a/app/core/gimpselection.h b/app/core/gimpselection.h
index 5315e0f..b707351 100644
--- a/app/core/gimpselection.h
+++ b/app/core/gimpselection.h
@@ -58,6 +58,15 @@ void          gimp_selection_load          (GimpSelection *selection,
                                             GimpChannel   *channel);
 GimpChannel * gimp_selection_save          (GimpSelection *selection);
 
+GeglBuffer  * gimp_selection_extract_buffer(GimpSelection *selection,
+                                            GimpPickable  *pickable,
+                                            GimpContext   *context,
+                                            gboolean       cut_image,
+                                            gboolean       keep_indexed,
+                                            gboolean       add_alpha,
+                                            gint          *offset_x,
+                                            gint          *offset_y,
+                                            GError       **error);
 TileManager * gimp_selection_extract       (GimpSelection *selection,
                                             GimpPickable  *pickable,
                                             GimpContext   *context,



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