[gimp] app: improve histogram bin calculation
- From: N/A <ell src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] app: improve histogram bin calculation
- Date: Wed, 8 Nov 2017 09:59:14 +0000 (UTC)
commit c49a21d95c10c5404e5ae534b37e74c1beac4d82
Author: Ell <ell_se yahoo com>
Date: Wed Nov 8 04:50:08 2017 -0500
app: improve histogram bin calculation
A fix to last commit: map values greater than G_MAXINT to the top
bin, not the bottom bin.
app/core/gimphistogram.c | 8 +++++---
1 files changed, 5 insertions(+), 3 deletions(-)
---
diff --git a/app/core/gimphistogram.c b/app/core/gimphistogram.c
index 1cf92d8..7beefb4 100644
--- a/app/core/gimphistogram.c
+++ b/app/core/gimphistogram.c
@@ -237,6 +237,7 @@ gimp_histogram_calculate (GimpHistogram *histogram,
const Babl *format;
gint n_components;
gint n_bins;
+ gfloat n_bins_1f;
gint temp;
g_return_if_fail (GIMP_IS_HISTOGRAM (histogram));
@@ -325,9 +326,10 @@ gimp_histogram_calculate (GimpHistogram *histogram,
babl_format ("Y float"),
GEGL_ACCESS_READ, GEGL_ABYSS_NONE);
-#define VALUE(c,i) (*(temp = SIGNED_ROUND ((i) * (priv->n_bins - 1)), \
- &priv->values[(c) * priv->n_bins + \
- CLAMP (temp, 0, priv->n_bins - 1)]))
+ n_bins_1f = priv->n_bins - 1;
+
+#define VALUE(c,i) (*(temp = SIGNED_ROUND (MIN ((i) * n_bins_1f, n_bins_1f)), \
+ &priv->values[(c) * priv->n_bins + MAX (temp, 0)]))
while (gegl_buffer_iterator_next (iter))
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]