[gimp/goat-invasion] app: clamp the return value of gimp_operation_levels_map_input()



commit 3252c8c50044dbc832ea07452ff229c90f234906
Author: Michael Natterer <mitch gimp org>
Date:   Wed May 2 14:26:25 2012 +0200

    app: clamp the return value of gimp_operation_levels_map_input()
    
    before putting it into 8 bit for rendering UI stuff, because the
    function itself doesn't clamp any longer.

 app/tools/gimplevelstool.c |   32 ++++++++++++++++++++------------
 1 files changed, 20 insertions(+), 12 deletions(-)
---
diff --git a/app/tools/gimplevelstool.c b/app/tools/gimplevelstool.c
index 7c3d9b9..7db2c36 100644
--- a/app/tools/gimplevelstool.c
+++ b/app/tools/gimplevelstool.c
@@ -837,6 +837,8 @@ levels_update_input_bar (GimpLevelsTool *tool)
 
   switch (config->channel)
     {
+      gdouble value;
+
     case GIMP_HISTOGRAM_VALUE:
     case GIMP_HISTOGRAM_ALPHA:
     case GIMP_HISTOGRAM_RGB:
@@ -846,9 +848,10 @@ levels_update_input_bar (GimpLevelsTool *tool)
 
         for (i = 0; i < 256; i++)
           {
-            v[i] = gimp_operation_levels_map_input (config,
-                                                    config->channel,
-                                                    i / 255.0) * 255.999;
+            value = gimp_operation_levels_map_input (config,
+                                                     config->channel,
+                                                     i / 255.0);
+            v[i] = CLAMP (value, 0.0, 1.0) * 255.999;
           }
 
         gimp_color_bar_set_buffers (GIMP_COLOR_BAR (tool->input_bar),
@@ -867,15 +870,20 @@ levels_update_input_bar (GimpLevelsTool *tool)
 
         for (i = 0; i < 256; i++)
           {
-            r[i] = gimp_operation_levels_map_input (config,
-                                                    GIMP_HISTOGRAM_RED,
-                                                    i / 255.0) * 255.999;
-            g[i] = gimp_operation_levels_map_input (config,
-                                                    GIMP_HISTOGRAM_GREEN,
-                                                    i / 255.0) * 255.999;
-            b[i] = gimp_operation_levels_map_input (config,
-                                                    GIMP_HISTOGRAM_BLUE,
-                                                    i / 255.0) * 255.999;
+            value = gimp_operation_levels_map_input (config,
+                                                     GIMP_HISTOGRAM_RED,
+                                                     i / 255.0);
+            r[i] = CLAMP (value, 0.0, 1.0) * 255.999;
+
+            value = gimp_operation_levels_map_input (config,
+                                                     GIMP_HISTOGRAM_GREEN,
+                                                     i / 255.0);
+            g[i] = CLAMP (value, 0.0, 1.0) * 255.999;
+
+            value = gimp_operation_levels_map_input (config,
+                                                     GIMP_HISTOGRAM_BLUE,
+                                                     i / 255.0);
+            b[i] = CLAMP (value, 0.0, 1.0) * 255.999;
           }
 
         gimp_color_bar_set_buffers (GIMP_COLOR_BAR (tool->input_bar),



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