Re: [boost] [GIL] color_convert

Hi,
I cannot recreate your problem. Here is a little test app that works fine on my machine ( VC10 )
The problem is that I define a generic conversion like that: /// \ingroup ColorConvert /// \brief Converting HSL to any pixel type. Note: Supports homogeneous pixels only. /// /// Done by an intermediate RGB conversion template <typename C2> struct default_color_converter_impl<hsl_t,C2> { template <typename P1, typename P2> void operator()(const P1& src, P2& dst) const { typedef hsl_t C1; typedef typename channel_type<P1>::type T1; typedef typename channel_type<P2>::type T2; pixel<T2,rgb_layout_t> tmp; default_color_converter_impl<C1,rgb_t>()(src, tmp); default_color_converter_impl<rgb_t,C2>()(tmp, dst); } }; So it's in conflict with: template <typename C1> struct default_color_converter_impl<C1, rgba_t>, if I use color_convert( hslPixel, rgbaPixel ). The goal of creating this generic conversion is that I can still make the conversion using an intermediate rgb colorspace if there is no specialization. I think we can have a good solution, if we apply this method to all colorspaces: * define a generic conversion to another colorspace using an intermediate rgb colorspace conversion, only in one direction MyColorspace -> typename C2 (so without typename C1 -> MyColorspace). That's why I would like to remove typename C1 -> rgba_t implementation. * redefine the conversion for colorspaces we want to make a direct conversion

Hi Fabien,
/// \ingroup ColorConvert /// \brief Converting HSL to any pixel type. Note: Supports homogeneous pixels only. /// /// Done by an intermediate RGB conversion template <typename C2> struct default_color_converter_impl<hsl_t,C2> { template <typename P1, typename P2> void operator()(const P1& src, P2& dst) const { typedef hsl_t C1; typedef typename channel_type<P1>::type T1; typedef typename channel_type<P2>::type T2; pixel<T2,rgb_layout_t> tmp; default_color_converter_impl<C1,rgb_t>()(src, tmp); default_color_converter_impl<rgb_t,C2>()(tmp, dst); } };
So it's in conflict with: template <typename C1> struct default_color_converter_impl<C1, rgba_t>, if I use color_convert( hslPixel, rgbaPixel ).
Yes, I have the conflict as well. I have been digging a little deeper in channel_convert.hpp. It defines the following color converters: default_color_converter_impl<gray_t,rgb_t> default_color_converter_impl<gray_t,cmyk_t> default_color_converter_impl<rgb_t,gray_t> default_color_converter_impl<rgb_t,cmyk_t> default_color_converter_impl<cmyk_t,rgb_t> default_color_converter_impl<cmyk_t,gray_t> default_color_converter_impl<C1,rgba_t> default_color_converter_impl<rgba_t,C2> default_color_converter_impl<rgba_t,rgba_t> Only for rgba gil is using partial specialization since it's using the rgb equivalent to do the wanted conversion. I think it's best to stick with total specialization to avoid confusions and/or breaking other people's code.
The goal of creating this generic conversion is that I can still make the conversion using an intermediate rgb colorspace if there is no specialization.
I think I just said that. ;-)
I think we can have a good solution, if we apply this method to all colorspaces:
* define a generic conversion to another colorspace using an intermediate rgb colorspace conversion, only in one direction MyColorspace -> typename C2 (so without typename C1 -> MyColorspace).
Even when converting from gray to cmyk you wanna create a temporary rgb value? I believe this is a bad idea for various reasons. Please correct me when I'm wrong. Regards, Christian
participants (2)
-
Christian Henning
-
fabien.castan@free.fr