Boost logo

Boost :

Subject: Re: [boost] [GIL] color_convert
From: Christian Henning (chhenning_at_[hidden])
Date: 2010-08-04 11:31:21


Hi there,

> I use the GIL extension: HSL.
> I need to make conversions from hsl to other colorspaces.
> So I define generic default conversion using intermediate rgb colorspace.
> I define 2 templates:
>  * default_color_convert<C1,hsl_t>
>  * default_color_convert<hsl_t,C2>
>
> But it creates an ambiguity with rgba_t, because it defines the same thing for rgba_t:
>  * default_color_convert<C1,rgba_t>
>  * default_color_convert<rgba_t,C2>
>
> So default_color_convert<hsl_t,rgba_t> is ambiguous.

I cannot recreate your problem. Here is a little test app that works
fine on my machine ( VC10 ):

#include <boost\gil\gil_all.hpp>
#include <boost\gil\extension\toolbox\hsl.hpp>

namespace boost { namespace gil {

template <>
struct default_color_converter_impl< rgba_t, hsl_t >
{
   template <typename P1, typename P2>
   void operator()( const P1& src, P2& dst ) const
   {
      using namespace hsl_color_space;

      int i = 9;

      // call default_color_converter_impl< rgb_t, hsl_t > eventually
   }
};

template <>
struct default_color_converter_impl<hsl_t,rgba_t>
{
   template <typename P1, typename P2>
   void operator()( const P1& src, P2& dst) const
   {
      using namespace hsl_color_space;

      int i = 9;
      // call default_color_converter_impl< hsl_t, rgb_t > eventually
   }
};

} // namespace gil
} // namespace boost

using namespace std;
using namespace boost;
using namespace gil;

int _tmain(int argc, _TCHAR* argv[])
{
    rgba8_pixel_t p( 128, 0, 128, 255 );
    hsl32f_pixel_t h;

    color_convert( p, h );
    color_convert( h, p );

        return 0;
}

You don't even need to specify the total specification. The current
implementation would multiply the alpha factor to all rgb channels and
then call rgb -> hsl converter. Do you have a different algorithm to
create a hsl pixel?

I haven't tried cmyk.

Regards,
Christian


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk