Re: [Gimp-developer] HSL patch

2007-01-12 Thread Sven Neumann
Hi,

On Thu, 2007-01-11 at 21:10 -0500, Robert L Krawitz wrote:

 Uh, maybe that I didn't look closely enough :-?  Here's an updated
 patch.

Thanks. I think it's about time that you open a bug report for this new
feature and attach your patch to it.  That's still the preferred way of
submitting patches.

 BTW, in the process of preparing this diff, I notice that the tarball
 contains devel-docs/app/Makefile, which almost surely it shouldn't.

The build rules for devel-docs/app are rather difficult as it shouldn't
be built by default but still the directory is supposed to be in the
tarball. The current solution is far from perfect as it allows glitches
to happen like the one you observed.


Sven


___
Gimp-developer mailing list
Gimp-developer@lists.XCF.Berkeley.EDU
https://lists.XCF.Berkeley.EDU/mailman/listinfo/gimp-developer


Re: [Gimp-developer] HSL patch

2007-01-12 Thread Robert L Krawitz
   From: Sven Neumann [EMAIL PROTECTED]
   Date: Fri, 12 Jan 2007 21:33:01 +0100

   On Thu, 2007-01-11 at 21:10 -0500, Robert L Krawitz wrote:

Uh, maybe that I didn't look closely enough :-?  Here's an updated
patch.

   Thanks. I think it's about time that you open a bug report for this
   new feature and attach your patch to it.  That's still the
   preferred way of submitting patches.

Done (bug 395928).

-- 
Robert Krawitz [EMAIL PROTECTED]

Tall Clubs International  --  http://www.tall.org/ or 1-888-IM-TALL-2
Member of the League for Programming Freedom -- mail [EMAIL PROTECTED]
Project lead for Gutenprint   --http://gimp-print.sourceforge.net

Linux doesn't dictate how I work, I dictate how Linux works.
--Eric Crampton
___
Gimp-developer mailing list
Gimp-developer@lists.XCF.Berkeley.EDU
https://lists.XCF.Berkeley.EDU/mailman/listinfo/gimp-developer


Re: [Gimp-developer] HSL patch

2007-01-11 Thread Robert L Krawitz
   From: Sven Neumann [EMAIL PROTECTED]
   Date: Thu, 11 Jan 2007 08:22:20 +0100

   On Wed, 2007-01-10 at 06:53 -0500, Robert L Krawitz wrote:
   From: Sven Neumann [EMAIL PROTECTED]
   Date: Wed, 10 Jan 2007 08:53:02 +0100

   can you explain to me why your patch introduces new functions in
   libgimpcolor? Couldn't you just use the existing gimp_rgb_to_hsl()
   and gimp_hsl_to_rgb()?

I did it the way I did to use the same implementation as the existing
compose_hsv() function.  In addition, it isn't clear to me why there
should be gimp_rgb_to_hsv4 but not gimp_rgb_to_hsl4.

   gimp_rgb_to_hsv4() is there for historical reasons. If we could, we
   would probably remove it from the API. I don't think we want to
   introduce a HSL variant of it now.

I'll try to get to it tonight, although I think it would be useful to
have the floating point version also -- if someone's writing a plugin
that's doing multiple transformations, it keeps more precision to do
the math in floating point vs. with chars.  In this case, I suggest
that the other floating point variants should be marked deprecated.
___
Gimp-developer mailing list
Gimp-developer@lists.XCF.Berkeley.EDU
https://lists.XCF.Berkeley.EDU/mailman/listinfo/gimp-developer


Re: [Gimp-developer] HSL patch

2007-01-11 Thread Sven Neumann
Hi,

On Thu, 2007-01-11 at 07:23 -0500, Robert L Krawitz wrote:

 I'll try to get to it tonight, although I think it would be useful to
 have the floating point version also -- if someone's writing a plugin
 that's doing multiple transformations, it keeps more precision to do
 the math in floating point vs. with chars.  In this case, I suggest
 that the other floating point variants should be marked deprecated.

But gimp_rgb_to_hsl() and gimp_hsl_to_rgb() are floating point versions.
What's your point?


Sven


___
Gimp-developer mailing list
Gimp-developer@lists.XCF.Berkeley.EDU
https://lists.XCF.Berkeley.EDU/mailman/listinfo/gimp-developer


Re: [Gimp-developer] HSL patch

2007-01-10 Thread Robert L Krawitz
   From: Sven Neumann [EMAIL PROTECTED]
   Date: Wed, 10 Jan 2007 08:53:02 +0100

   can you explain to me why your patch introduces new functions in
   libgimpcolor? Couldn't you just use the existing gimp_rgb_to_hsl()
   and gimp_hsl_to_rgb()?

I did it the way I did to use the same implementation as the existing
compose_hsv() function.  In addition, it isn't clear to me why there
should be gimp_rgb_to_hsv4 but not gimp_rgb_to_hsl4.

-- 
Robert Krawitz [EMAIL PROTECTED]

Tall Clubs International  --  http://www.tall.org/ or 1-888-IM-TALL-2
Member of the League for Programming Freedom -- mail [EMAIL PROTECTED]
Project lead for Gutenprint   --http://gimp-print.sourceforge.net

Linux doesn't dictate how I work, I dictate how Linux works.
--Eric Crampton
___
Gimp-developer mailing list
Gimp-developer@lists.XCF.Berkeley.EDU
https://lists.XCF.Berkeley.EDU/mailman/listinfo/gimp-developer


Re: [Gimp-developer] HSL patch

2007-01-10 Thread Sven Neumann
Hi,

On Wed, 2007-01-10 at 06:53 -0500, Robert L Krawitz wrote:
From: Sven Neumann [EMAIL PROTECTED]
Date: Wed, 10 Jan 2007 08:53:02 +0100
 
can you explain to me why your patch introduces new functions in
libgimpcolor? Couldn't you just use the existing gimp_rgb_to_hsl()
and gimp_hsl_to_rgb()?
 
 I did it the way I did to use the same implementation as the existing
 compose_hsv() function.  In addition, it isn't clear to me why there
 should be gimp_rgb_to_hsv4 but not gimp_rgb_to_hsl4.

gimp_rgb_to_hsv4() is there for historical reasons. If we could, we
would probably remove it from the API. I don't think we want to
introduce a HSL variant of it now.


Sven


___
Gimp-developer mailing list
Gimp-developer@lists.XCF.Berkeley.EDU
https://lists.XCF.Berkeley.EDU/mailman/listinfo/gimp-developer


[Gimp-developer] HSL patch

2007-01-09 Thread Robert L Krawitz
Unfortunately, there's a little bug in the HSL compose patch, in
gimp_hsl_to_rgb4 in the case of zero saturation.  This fixes that.

I'd like to have an option to use luminosity rather than value in
curves and layers; I'm not sure how to do it without introducing
additional complexity.
--- ./libgimpcolor/gimpcolorspace.c~2006-06-27 06:33:48.0 -0400
+++ ./libgimpcolor/gimpcolorspace.c 2007-01-06 14:57:28.0 -0500
@@ -1003,6 +1003,90 @@
 }
 
 /**
+ * gimp_rgb_to_hsl4:
+ * @rgb:RGB triplet, rgb[0] is red channel, rgb[1] is green,
+ *  rgb[2] is blue (0..255)
+ * @hue:Pointer to hue channel (0..1)
+ * @saturation: Pointer to saturation channel (0..1)
+ * @luma:   Pointer to luma channel (0..1)
+ *
+ * Convert an RGB color value to an HSL (Hue, Saturation, Lightness)
+ * color value.
+ *
+ * Since: GIMP 2.4
+ **/
+void
+gimp_rgb_to_hsl4 (const guchar *rgb,
+  gdouble  *hue,
+  gdouble  *saturation,
+  gdouble  *luma)
+{
+  gdouble red, green, blue;
+  gdouble h, s, l;
+  gdouble min, max;
+  gdouble delta;
+
+  red   = rgb[0] / 255.0;
+  green = rgb[1] / 255.0;
+  blue  = rgb[2] / 255.0;
+
+  h = 0.0; /* Shut up -Wall */
+
+  if (red  green)
+{
+  max = MAX (red,   blue);
+  min = MIN (green, blue);
+}
+  else
+{
+  max = MAX (green, blue);
+  min = MIN (red,   blue);
+}
+
+  l = (max + min) / 2.0;
+
+  if (max == min)
+{
+  s = 0.0;
+  h = GIMP_HSL_UNDEFINED;
+}
+  else
+{
+  if (l = 0.5)
+s = (max - min) / (max + min);
+  else
+s = (max - min) / (2.0 - max - min);
+
+  delta = max - min;
+
+  if (delta == 0.0)
+delta = 1.0;
+
+  if (red == max)
+{
+  h = (green - blue) / delta;
+}
+  else if (green == max)
+{
+  h = 2.0 + (blue - red) / delta;
+}
+  else if (blue == max)
+{
+  h = 4.0 + (red - green) / delta;
+}
+
+  h /= 6.0;
+
+  if (h  0.0)
+h += 1.0;
+}
+
+  *hue= h;
+  *saturation = s;
+  *luma   = l;
+}
+
+/**
  * gimp_hsv_to_rgb4:
  * @rgb:RGB triplet, rgb[0] is red channel, rgb[1] is green,
  *  rgb[2] is blue (0..255)
@@ -1083,3 +1167,45 @@
   rgb[1] = ROUND (saturation * 255.0);
   rgb[2] = ROUND (value  * 255.0);
 }
+
+/**
+ * gimp_hsl_to_rgb4:
+ * @rgb:RGB triplet, rgb[0] is red channel, rgb[1] is green,
+ *  rgb[2] is blue (0..255)
+ * @hue:Hue channel (0..1)
+ * @saturation: Saturation channel (0..1)
+ * @luma:   Luma channel (0..1)
+ *
+ * Convert an HSL color value (Hue, Saturation, Lightness) to an RGB
+ * color value.
+ *
+ * Since: GIMP 2.4
+ **/
+void
+gimp_hsl_to_rgb4 (guchar  *rgb,
+  gdouble  hue,
+  gdouble  saturation,
+  gdouble  luma)
+{
+  if (saturation == 0.0)
+{
+  rgb[0] = ROUND(luma * 255.0);
+  rgb[1] = ROUND(luma * 255.0);
+  rgb[2] = ROUND(luma * 255.0);
+}
+  else
+{
+  gdouble m1, m2;
+
+  if (luma = 0.5)
+m2 = luma * (1.0 + saturation);
+  else
+m2 = luma + saturation - luma * saturation;
+
+  m1 = 2.0 * luma - m2;
+
+  rgb[0] = ROUND (gimp_hsl_value (m1, m2, hue * 6.0 + 2.0) * 255.0);
+  rgb[1] = ROUND (gimp_hsl_value (m1, m2, hue * 6.0)   * 255.0);
+  rgb[2] = ROUND (gimp_hsl_value (m1, m2, hue * 6.0 - 2.0) * 255.0);
+}
+}
--- ./libgimpcolor/gimpcolorspace.h~2006-06-27 06:33:48.0 -0400
+++ ./libgimpcolor/gimpcolorspace.h 2007-01-06 13:07:47.0 -0500
@@ -94,6 +94,14 @@
  gdouble   hue,
  gdouble   saturation,
  gdouble   value);
+voidgimp_rgb_to_hsl4(const guchar *rgb,
+ gdouble  *hue,
+ gdouble  *saturation,
+ gdouble  *luma);
+voidgimp_hsl_to_rgb4(guchar   *rgb,
+ gdouble   hue,
+ gdouble   saturation,
+ gdouble   luma);
 
 
 G_END_DECLS
--- ./libgimpcolor/gimpcolor.def~   2006-09-01 07:14:32.0 -0400
+++ ./libgimpcolor/gimpcolor.def2007-01-06 14:42:27.0 -0500
@@ -18,6 +18,7 @@
gimp_cmyka_set_uchar
gimp_hsl_get_type
gimp_hsl_to_rgb
+   gimp_hsl_to_rgb4
gimp_hsl_to_rgb_int
gimp_hsv_clamp
gimp_hsv_get_type
@@ -55,6 +56,7 @@
gimp_rgb_to_cmyk
gimp_rgb_to_cmyk_int
gimp_rgb_to_hsl
+   gimp_rgb_to_hsl4
gimp_rgb_to_hsl_int
gimp_rgb_to_hsv
gimp_rgb_to_hsv4
--- ./plug-ins/common/decompose.c~  2006-06-27 06:33:49.0 -0400
+++ ./plug-ins/common/decompose.c   2007-01-06 

Re: [Gimp-developer] HSL patch

2007-01-09 Thread Sven Neumann
Hi,

can you explain to me why your patch introduces new functions in
libgimpcolor? Couldn't you just use the existing gimp_rgb_to_hsl() and
gimp_hsl_to_rgb()?


Sven


___
Gimp-developer mailing list
Gimp-developer@lists.XCF.Berkeley.EDU
https://lists.XCF.Berkeley.EDU/mailman/listinfo/gimp-developer