[gegl/soc-2011-warp: 19/20] implement support for format_n buffer in the nearest neighbour sampler (not sure if working yet)



commit 9a62bc4d2281343a8b3553d9f56ed2fbedc70e93
Author: Michael Murà <batolettre gmail com>
Date:   Sun Sep 4 20:36:02 2011 +0200

    implement support for format_n buffer in the nearest neighbour sampler (not sure if working yet)

 gegl/buffer/gegl-sampler-nearest.c |   18 +++++++++++++++---
 gegl/buffer/gegl-sampler.h         |    4 ++--
 2 files changed, 17 insertions(+), 5 deletions(-)
---
diff --git a/gegl/buffer/gegl-sampler-nearest.c b/gegl/buffer/gegl-sampler-nearest.c
index 46fd9a1..321a992 100644
--- a/gegl/buffer/gegl-sampler-nearest.c
+++ b/gegl/buffer/gegl-sampler-nearest.c
@@ -78,9 +78,21 @@ gegl_sampler_nearest_get (GeglSampler *self,
                           GeglMatrix2 *scale,
                           void        *output)
 {
-  gfloat             *sampler_bptr;
-  sampler_bptr = gegl_sampler_get_from_buffer (self, (gint)x, (gint)y);
-  babl_process (babl_fish (self->interpolate_format, self->format), sampler_bptr, output, 1);
+  if (!babl_format_is_format_n (self->format))
+    {
+      gfloat  *sampler_bptr;
+      sampler_bptr = gegl_sampler_get_from_buffer (self, (gint)x, (gint)y);
+
+      babl_process (babl_fish (self->interpolate_format, self->format), sampler_bptr, output, 1);
+    }
+  else
+    {
+      void  *data;
+      gint nbyte;
+      data = gegl_sampler_get_from_buffer (self, (gint)x, (gint)y);
+      nbyte = babl_format_get_bytes_per_pixel (self->format);
+      memcpy (output, data, nbyte);
+    }
 }
 
 static void
diff --git a/gegl/buffer/gegl-sampler.h b/gegl/buffer/gegl-sampler.h
index 1e5b5f7..330b0e0 100644
--- a/gegl/buffer/gegl-sampler.h
+++ b/gegl/buffer/gegl-sampler.h
@@ -50,8 +50,8 @@ struct _GeglSampler
 
   /*< private >*/
   GeglBuffer    *buffer;
-  Babl          *format;
-  Babl          *interpolate_format;
+  Babl          *format; /* the format asked to return the data */
+  Babl          *interpolate_format; /* the format used by the sampler to interpolate */
   Babl          *fish;
   GeglRectangle  context_rect[GEGL_SAMPLER_MIPMAP_LEVELS];
   gpointer       sampler_buffer[GEGL_SAMPLER_MIPMAP_LEVELS];



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