Skip to content
Browse files

Use ConvertHSLToRGB, ConvertRGBToHSL when available.

  • Loading branch information...
1 parent 09e00a1 commit 2bf62237ab1f59f6b6f45ac162b538f270cc0e19 rmagick committed Sep 16, 2007
Showing with 17 additions and 1 deletion.
  1. +1 −0 configure.ac
  2. +4 −0 ext/RMagick/rmagick_config.h.in
  3. +12 −1 ext/RMagick/rmutil.c
View
1 configure.ac
@@ -105,6 +105,7 @@ AC_CHECK_FUNCS([AdaptiveThresholdImage AddDefinitions])
AC_CHECK_FUNCS([AddNoiseImageChannel BilevelImageChannel BlackThresholdImage])
AC_CHECK_FUNCS([BlurImageChannel ClearMagickException CompareImageChannels])
AC_CHECK_FUNCS([CompareImageLayers CompositeImageChannel ContrastStretchImageChannel])
+AC_CHECK_FUNCS([ConvertHSLToRGB ConvertRGBToHSL])
AC_CHECK_FUNCS([ConvolveImageChannel EvaluateImageChannel ExportImagePixels])
AC_CHECK_FUNCS([FuzzyColorCompare FxImageChannel GammaImageChannel])
AC_CHECK_FUNCS([GaussianBlurImageChannel GetColorHistogram GetColorInfoArray])
View
4 ext/RMagick/rmagick_config.h.in
@@ -37,6 +37,10 @@
#undef HAVE_COMPOSITEIMAGECHANNEL
/* Introduced in IM 6.2.6 */
#undef HAVE_CONTRASTSTRETCHIMAGECHANNEL
+/* Introduced in IM 6.3.5-9 */
+#undef HAVE_CONVERTHSLTORGB
+/* Introduced in IM 6.3.5-9 */
+#undef HAVE_CONVERTRGBTOHSL
/* Introduced in IM 6.0.1 */
#undef HAVE_CONVOLVEIMAGECHANNEL
/* Introduced in IM 6.0.0 */
View
13 ext/RMagick/rmutil.c
@@ -1,4 +1,4 @@
-/* $Id: rmutil.c,v 1.90.2.3 2007/06/09 16:45:52 rmagick Exp $ */
+/* $Id: rmutil.c,v 1.90.2.3.2.1 2007/09/16 21:38:42 rmagick Exp $ */
/*============================================================================\
| Copyright (C) 2007 by Timothy P. Hunter
| Name: rmutil.c
@@ -604,7 +604,12 @@ Pixel_to_HSL(VALUE self)
volatile VALUE hsl;
Data_Get_Struct(self, Pixel, pixel);
+
+#if defined(HAVE_CONVERTRGBTOHSL)
+ ConvertRGBToHSL(pixel->red, pixel->green, pixel->blue, &hue, &saturation, &luminosity);
+#else
TransformHSL(pixel->red, pixel->green, pixel->blue, &hue, &saturation, &luminosity);
+#endif
hsl = rb_ary_new3(3, rb_float_new(hue), rb_float_new(saturation),
rb_float_new(luminosity));
@@ -635,8 +640,14 @@ Pixel_from_HSL(VALUE class, VALUE hsl)
saturation = NUM2DBL(rb_ary_entry(hsl, 1));
luminosity = NUM2DBL(rb_ary_entry(hsl, 2));
+#if defined(HAVE_CONVERTHSLTORGB)
+ ConvertHSLToRGB(hue, saturation, luminosity,
+ &rgb.red, &rgb.green, &rgb.blue);
+#else
HSLTransform(hue, saturation, luminosity,
&rgb.red, &rgb.green, &rgb.blue);
+#endif
+
return Pixel_from_PixelPacket(&rgb);
}

0 comments on commit 2bf6223

Please sign in to comment.
Something went wrong with that request. Please try again.