gimp r27001 - in trunk: . app/core app/gegl



Author: simon
Date: Thu Sep 18 19:48:04 2008
New Revision: 27001
URL: http://svn.gnome.org/viewvc/gimp?rev=27001&view=rev

Log:
2008-09-18  Simon Budig  <simon gimp org>

	* app/core/gimpcurve.c: comment fix

	* app/gegl/gimplevelsconfig.c: improve the levels->curves
	transition. Not perfect, the result does not match a "real"
	gamma correction, especially in the dark areas, where the
	curves are too dark compared to the levels.



Modified:
   trunk/ChangeLog
   trunk/app/core/gimpcurve.c
   trunk/app/gegl/gimplevelsconfig.c

Modified: trunk/app/core/gimpcurve.c
==============================================================================
--- trunk/app/core/gimpcurve.c	(original)
+++ trunk/app/core/gimpcurve.c	Thu Sep 18 19:48:04 2008
@@ -977,7 +977,7 @@
 
   /*
    * the x values of the inner control points are fixed at
-   * x1 = 1/3*x0 + 2/3*x3   and  x2 = 2/3*x0 + 1/3*x3
+   * x1 = 2/3*x0 + 1/3*x3   and  x2 = 1/3*x0 + 2/3*x3
    * this ensures that the x values increase linearily with the
    * parameter t and enables us to skip the calculation of the x
    * values altogehter - just calculate y(t) evenly spaced.

Modified: trunk/app/gegl/gimplevelsconfig.c
==============================================================================
--- trunk/app/gegl/gimplevelsconfig.c	(original)
+++ trunk/app/gegl/gimplevelsconfig.c	Thu Sep 18 19:48:04 2008
@@ -597,38 +597,26 @@
        channel++)
     {
       GimpCurve *curve = curves->curve[channel];
-      gint       border_point;
-      gint       point;
+      gdouble    gamma = config->gamma[channel];
+      gdouble    delta_in  = config->high_input[channel] - config->low_input[channel];
+      gdouble    delta_out = config->high_output[channel] - config->low_output[channel];
+
+      gimp_curve_set_point (curve, 0,
+                            config->low_input[channel],
+                            config->low_output[channel]);
 
-      if (config->low_input[channel]  > 0.0 ||
-          config->low_output[channel] > 0.0)
+      if (delta_out != 0 && gamma != 1.0)
         {
-          border_point = gimp_curve_get_closest_point (curve, 0.0);
-          point = gimp_curve_get_closest_point (curve,
-                                                config->low_input[channel]);
-
-          gimp_curve_set_point (curve, point,
-                                config->low_input[channel],
-                                config->low_output[channel]);
-
-          if (point != border_point)
-            gimp_curve_set_point (curve, border_point, -1, -1);
+          gimp_curve_set_point (curve, curve->n_points / 2,
+                                config->low_input[channel]  +
+                                  pow (gamma, gamma / (1 - gamma)) * delta_in,
+                                config->low_output[channel] +
+                                  pow (gamma, 1.0 / (1 - gamma)) * delta_out);
         }
 
-      if (config->high_input[channel]  < 1.0 ||
-          config->high_output[channel] < 1.0)
-        {
-          border_point = gimp_curve_get_closest_point (curve, 1.0);
-          point = gimp_curve_get_closest_point (curve,
-                                                config->high_input[channel]);
-
-          gimp_curve_set_point (curve, point,
-                                config->high_input[channel],
-                                config->high_output[channel]);
-
-          if (point != border_point)
-            gimp_curve_set_point (curve, border_point, -1, -1);
-        }
+      gimp_curve_set_point (curve, curve->n_points - 1,
+                            config->high_input[channel],
+                            config->high_output[channel]);
     }
 
   return curves;



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