[gegl] nearest.c: clearer code and comments
- From: Nicolas Robidoux <nrobidoux src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gegl] nearest.c: clearer code and comments
- Date: Fri, 23 Nov 2012 13:03:09 +0000 (UTC)
commit 3875cd7fa491f7b8b032404c0d592657ebaeab57
Author: Nicolas Robidoux <nrobidoux git gnome org>
Date: Fri Nov 23 07:58:34 2012 -0500
nearest.c: clearer code and comments
gegl/buffer/gegl-sampler-nearest.c | 23 +++++++++++++++--------
1 files changed, 15 insertions(+), 8 deletions(-)
---
diff --git a/gegl/buffer/gegl-sampler-nearest.c b/gegl/buffer/gegl-sampler-nearest.c
index 648ccf7..fa803dc 100644
--- a/gegl/buffer/gegl-sampler-nearest.c
+++ b/gegl/buffer/gegl-sampler-nearest.c
@@ -35,8 +35,8 @@ enum
static void
gegl_sampler_nearest_get (GeglSampler *self,
- gdouble x,
- gdouble y,
+ gdouble absolute_x,
+ gdouble absolute_y,
GeglMatrix2 *scale,
void *output,
GeglAbyssPolicy repeat_mode);
@@ -63,17 +63,24 @@ gegl_sampler_nearest_init (GeglSamplerNearest *self)
void
gegl_sampler_nearest_get (GeglSampler *self,
- gdouble x,
- gdouble y,
+ gdouble absolute_x,
+ gdouble absolute_y,
GeglMatrix2 *scale,
void *output,
GeglAbyssPolicy repeat_mode)
{
gfloat *sampler_bptr;
- sampler_bptr = gegl_sampler_get_from_buffer (self,
- (gint) floor ((double) x),
- (gint) floor ((double) y),
- repeat_mode);
+ /*
+ * The reason why floor of the absolute position gives the nearest
+ * pixel (with ties resolved toward -infinity) is that the absolute
+ * position is corner based (origin at the top left corner of the
+ * pixel labeled (0,0).
+ */
+ sampler_bptr =
+ gegl_sampler_get_from_buffer (self,
+ (gint) floor ((double) absolute_x),
+ (gint) floor ((double) absolute_y),
+ repeat_mode);
babl_process (self->fish, sampler_bptr, output, 1);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]