gimp r26883 - in trunk: . app/gegl



Author: martinn
Date: Sat Sep  6 06:53:43 2008
New Revision: 26883
URL: http://svn.gnome.org/viewvc/gimp?rev=26883&view=rev

Log:
Bug 527085 â Hue/Saturation (working improperly)

* app/gegl/gimpoperationhuesaturation.c
(gimp_operation_hue_saturation_process): Properly map the
secondary hue. Based on patch by Michael Deal.


Modified:
   trunk/ChangeLog
   trunk/app/gegl/gimpoperationhuesaturation.c

Modified: trunk/app/gegl/gimpoperationhuesaturation.c
==============================================================================
--- trunk/app/gegl/gimpoperationhuesaturation.c	(original)
+++ trunk/app/gegl/gimpoperationhuesaturation.c	Sat Sep  6 06:53:43 2008
@@ -207,14 +207,33 @@
 
       if (use_secondary_hue)
         {
-          hsl.h = (map_hue        (config, hue,           hsl.h) * primary_intensity +
-                   map_hue        (config, secondary_hue, hsl.h) * secondary_intensity);
+          gdouble mapped_primary;
+          gdouble mapped_secondary;
+          gdouble diff;
+
+          mapped_primary   = map_hue (config, hue, hsl.h);
+          mapped_secondary = map_hue (config, secondary_hue, hsl.h);
+
+          // Find nearest hue on the circle between primary and
+          // secondary hue
+          diff = mapped_primary - mapped_secondary;
+          if (diff < -0.5)
+            {
+              mapped_secondary -= 1.0;
+            }
+          else if (diff >= 0.5)
+            {
+              mapped_secondary += 1.0;
+            }
 
-          hsl.s = (map_saturation (config, hue,           hsl.s) * primary_intensity +
-                   map_saturation (config, secondary_hue, hsl.s) * secondary_intensity);
+          hsl.h = mapped_primary   * primary_intensity +
+                  mapped_secondary * secondary_intensity;
 
-          hsl.l = (map_lightness  (config, hue,           hsl.l) * primary_intensity +
-                   map_lightness  (config, secondary_hue, hsl.l) * secondary_intensity);
+          hsl.s = map_saturation (config, hue,           hsl.s) * primary_intensity +
+                  map_saturation (config, secondary_hue, hsl.s) * secondary_intensity;
+
+          hsl.l = map_lightness (config, hue,           hsl.l) * primary_intensity +
+                  map_lightness (config, secondary_hue, hsl.l) * secondary_intensity;
         }
       else
         {



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