[gimp] app: create > 8-bit histograms with 1024 bins



commit 48d312ed948819cab8f0890e96fd5a618318fbd4
Author: Michael Natterer <mitch gimp org>
Date:   Tue Jun 11 08:49:28 2013 +0200

    app: create > 8-bit histograms with 1024 bins
    
    Seems to calculate and draw correctly, just the view's range is
    broken now, will fix.

 app/core/gimphistogram.c |   18 ++++++++++++++----
 1 files changed, 14 insertions(+), 4 deletions(-)
---
diff --git a/app/core/gimphistogram.c b/app/core/gimphistogram.c
index 35e4652..6963241 100644
--- a/app/core/gimphistogram.c
+++ b/app/core/gimphistogram.c
@@ -44,7 +44,8 @@ struct _GimpHistogram
 /*  local function prototypes  */
 
 static void   gimp_histogram_alloc_values (GimpHistogram *histogram,
-                                           gint           n_components);
+                                           gint           n_components,
+                                           gint           n_bins);
 
 
 /*  public functions  */
@@ -120,6 +121,7 @@ gimp_histogram_calculate (GimpHistogram       *histogram,
   GeglBufferIterator *iter;
   const Babl         *format;
   gint                n_components;
+  gint                n_bins;
 
   g_return_if_fail (histogram != NULL);
   g_return_if_fail (GEGL_IS_BUFFER (buffer));
@@ -127,6 +129,11 @@ gimp_histogram_calculate (GimpHistogram       *histogram,
 
   format = gegl_buffer_get_format (buffer);
 
+  if (babl_format_get_type (format, 0) == babl_type ("u8"))
+    n_bins = 256;
+  else
+    n_bins = 1024;
+
   if (babl_format_is_palette (format))
     {
       if (babl_format_has_alpha (format))
@@ -178,7 +185,7 @@ gimp_histogram_calculate (GimpHistogram       *histogram,
 
   n_components = babl_format_get_n_components (format);
 
-  gimp_histogram_alloc_values (histogram, n_components);
+  gimp_histogram_alloc_values (histogram, n_components, n_bins);
 
   iter = gegl_buffer_iterator_new (buffer, buffer_rect, 0, format,
                                    GEGL_BUFFER_READ, GEGL_ABYSS_NONE);
@@ -737,13 +744,16 @@ gimp_histogram_get_std_dev (GimpHistogram        *histogram,
 
 static void
 gimp_histogram_alloc_values (GimpHistogram *histogram,
-                             gint           n_components)
+                             gint           n_components,
+                             gint           n_bins)
 {
-  if (n_components + 1 != histogram->n_channels)
+  if (n_components + 1 != histogram->n_channels ||
+      n_bins != histogram->n_bins)
     {
       gimp_histogram_clear_values (histogram);
 
       histogram->n_channels = n_components + 1;
+      histogram->n_bins     = n_bins;
 
       histogram->values = g_new0 (gdouble,
                                   histogram->n_channels * histogram->n_bins);


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