[gimp] app: must CLAMP() all valus to 0..1 for calculating histogram bins



commit 0f0590426df546e0fe8fa46ea696b9614d939278
Author: Michael Natterer <mitch gimp org>
Date:   Tue Jun 11 23:11:37 2013 +0200

    app: must CLAMP() all valus to 0..1 for calculating histogram bins
    
    The histogram does only 0..1, there are no bins outside that range.

 app/core/gimphistogram.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)
---
diff --git a/app/core/gimphistogram.c b/app/core/gimphistogram.c
index a403c82..f87a8b1 100644
--- a/app/core/gimphistogram.c
+++ b/app/core/gimphistogram.c
@@ -307,7 +307,9 @@ gimp_histogram_calculate (GimpHistogram       *histogram,
                               babl_format ("Y float"),
                               GEGL_BUFFER_READ, GEGL_ABYSS_NONE);
 
-#define VALUE(c,i) (priv->values[(c) * priv->n_bins + (gint) ((i) * (priv->n_bins - 0.0001))])
+#define VALUE(c,i) (priv->values[(c) * priv->n_bins + \
+                                 (gint) (CLAMP ((i), 0.0, 1.0) * \
+                                         (priv->n_bins - 0.0001))])
 
   while (gegl_buffer_iterator_next (iter))
     {


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