gegl r2907 - in trunk: . operations/common



Author: martinn
Date: Thu Feb 12 06:47:46 2009
New Revision: 2907
URL: http://svn.gnome.org/viewvc/gegl?rev=2907&view=rev

Log:
Add a 'format' property to gegl:buffer-sink

Modified:
   trunk/ChangeLog
   trunk/operations/common/buffer-sink.c

Modified: trunk/operations/common/buffer-sink.c
==============================================================================
--- trunk/operations/common/buffer-sink.c	(original)
+++ trunk/operations/common/buffer-sink.c	Thu Feb 12 06:47:46 2009
@@ -24,6 +24,8 @@
 
 gegl_chant_pointer (buffer, _("Buffer location"),
                     _("The location where to store the output GeglBuffer"))
+gegl_chant_pointer (format, _("babl format"),
+                    _("The babl format of the output GeglBuffer, NULL to use input buffer format"))
 
 #else
 
@@ -39,12 +41,24 @@
 {
   GeglChantO *o = GEGL_CHANT_PROPERTIES (operation);
 
-  if (o->buffer)
+  if (o->buffer != NULL &&
+      (o->format == NULL || o->format == gegl_buffer_get_format (input)))
     {
       GeglBuffer **output = o->buffer;
 
       *output = gegl_buffer_create_sub_buffer (input, result);
     }
+  else if (o->buffer != NULL &&
+           o->format != NULL)
+    {
+      GeglBuffer **output = o->buffer;
+
+      *output = gegl_buffer_new (gegl_buffer_get_extent (input),
+                                 o->format);
+
+      gegl_buffer_copy (input, NULL,
+                        *output, NULL);
+    }
 
   return TRUE;
 }



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