[gegl] lohalo sampler does not perform the conversion from absolute (corner-based) coordinates to index (ce
- From: Nicolas Robidoux <nrobidoux src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gegl] lohalo sampler does not perform the conversion from absolute (corner-based) coordinates to index (ce
- Date: Mon, 19 Nov 2012 15:58:22 +0000 (UTC)
commit 84c595694283567986ddaff189164199cdf43bbe
Author: Nicolas Robidoux <nrobidoux git gnome org>
Date: Mon Nov 19 10:58:12 2012 -0500
lohalo sampler does not perform the conversion from absolute (corner-based) coordinates to index (center-based) coordinates twice
gegl/buffer/gegl-sampler-lohalo.c | 19 ++++++++++++++-----
1 files changed, 14 insertions(+), 5 deletions(-)
---
diff --git a/gegl/buffer/gegl-sampler-lohalo.c b/gegl/buffer/gegl-sampler-lohalo.c
index 3b8afd1..49da984 100644
--- a/gegl/buffer/gegl-sampler-lohalo.c
+++ b/gegl/buffer/gegl-sampler-lohalo.c
@@ -1310,13 +1310,22 @@ gegl_sampler_lohalo_get ( GeglSampler* restrict self,
(gfloat*) gegl_sampler_get_ptr (self, ix_0, iy_0, repeat_mode);
/*
+ * First, we convert from the absolute position in the coordinate
+ * system with origin at the top left corner of the pixel with index
+ * (0,0) (the "GIMP convention" a.k.a. "corner-based"), to the
+ * position in the coordinate system with origin at the center of
+ * the pixel with index (0,0) (the "index" convention
+ * a.k.a. "center-based").
+ */
+ const gdouble iabsolute_x = absolute_x - (gdouble) 0.5;
+ const gdouble iabsolute_y = absolute_y - (gdouble) 0.5;
+
+ /*
* (x_0,y_0) is the relative position of the sampling location
- * w.r.t. the anchor pixel. The "+1/2"s are because the center of
- * the pixel with index (0,0) is located at (1/2,1/2) within the
- * GIMP convention.
+ * w.r.t. the anchor pixel.
*/
- const gfloat x_0 = absolute_x - ( ix_0 + (gdouble) 0.5 );
- const gfloat y_0 = absolute_y - ( iy_0 + (gdouble) 0.5 );
+ const gfloat x_0 = iabsolute_x - ix_0;
+ const gfloat y_0 = iabsolute_y - iy_0;
const gint sign_of_x_0 = 2 * ( x_0 >= (gfloat) 0. ) - 1;
const gint sign_of_y_0 = 2 * ( y_0 >= (gfloat) 0. ) - 1;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]