|
Boost : |
Subject: Re: [boost] [GIL] color_convert
From: Christian Henning (chhenning_at_[hidden])
Date: 2010-08-05 13:28:18
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
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk