[gthumb] histogram: simplified code to get the cumulative histogram



commit e5bda431a8dcb1b9c2c8f88c5fdd7b36c81cf49f
Author: Paolo Bacchilega <paobac src gnome org>
Date:   Tue Dec 31 13:00:38 2013 +0100

    histogram: simplified code to get the cumulative histogram

 gthumb/gth-histogram.c |    9 ++++++---
 1 files changed, 6 insertions(+), 3 deletions(-)
---
diff --git a/gthumb/gth-histogram.c b/gthumb/gth-histogram.c
index 238f6a6..727f387 100644
--- a/gthumb/gth-histogram.c
+++ b/gthumb/gth-histogram.c
@@ -285,10 +285,13 @@ gth_histogram_get_cumulative (GthHistogram *self)
 
        cumulative = g_new (long *, GTH_HISTOGRAM_N_CHANNELS);
        for (c = 0; c < GTH_HISTOGRAM_N_CHANNELS; c++) {
+               int s;
+
                cumulative[c] = g_new (long, 256);
-               cumulative[c][0] = gth_histogram_get_value (self, c, 0);
-               for (v = 1; v < 256; v++) {
-                       cumulative[c][v] = gth_histogram_get_value (self, c, v) + cumulative[c][v - 1];
+               s = 0;
+               for (v = 0; v < 256; v++) {
+                       s += gth_histogram_get_value (self, c, v);
+                       cumulative[c][v] = s;
                }
        }
 


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