[gimp/gimp-2-10] Issue #4205 - The histogram dock scale is incorrect when an image is opened



commit 9f8e244ec1f32bc70ea34e9df02cbf2633a126a8
Author: Ell <ell_se yahoo com>
Date:   Mon Nov 11 18:11:39 2019 +0200

    Issue #4205 - The histogram dock scale is incorrect when an image is opened
    
    In gimp_histogram_view_update_bins(), don't update the view's
    range if there's no histogram or the histogram is empty, to avoid
    discarding the existing range.  Additionally, improve the range
    readjustment when the number of bins changes.
    
    (cherry picked from commit 0c899394b4b95b8f25b3d73c6d3cff2cd700be6c)

 app/widgets/gimphistogramview.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)
---
diff --git a/app/widgets/gimphistogramview.c b/app/widgets/gimphistogramview.c
index bc44dca7f4..ccf1f51003 100644
--- a/app/widgets/gimphistogramview.c
+++ b/app/widgets/gimphistogramview.c
@@ -799,21 +799,21 @@ gimp_histogram_view_notify (GimpHistogram     *histogram,
 static void
 gimp_histogram_view_update_bins (GimpHistogramView *view)
 {
-  gint new_bins = 256;
+  gint new_bins = 0;
 
   if (view->histogram)
     new_bins = gimp_histogram_n_bins (view->histogram);
   else if (view->bg_histogram)
     new_bins = gimp_histogram_n_bins (view->bg_histogram);
 
-  if (new_bins != view->n_bins)
+  if (new_bins > 0 && new_bins != view->n_bins)
     {
-      view->start = ROUND (((gdouble) view->start *
-                            (new_bins - 1) /
-                            (view->n_bins - 1)));
-      view->end   = ROUND (((gdouble) view->end   *
-                            (new_bins - 1) /
-                            (view->n_bins - 1)));
+      view->start = MIN (ROUND ((gdouble) view->start *
+                                new_bins / view->n_bins),
+                         new_bins - 1);
+      view->end   = MAX (ROUND ((gdouble) (view->end + 1) *
+                                new_bins / view->n_bins) - 1,
+                         0);
 
       view->n_bins = new_bins;
 


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