2010-03-30 38 views
2

我有一个模板<PIXEL>,假设是boost::gil的像素类型之一(目前,只有gray8_pixel_tgray16_pixel_t,我只希望支持同质像素类型,例如rgb8_pixel_t将来)之一。如何从boost :: gil同类像素类型中提取通道POD类型?

该类需要根据像素类型获得unsigned charunsigned short;我认为这是像素类掩埋somehwere,但没有PIXEL::value_typePIXEL::channel_typePIXEL::channel_type::value type似乎是我想要的。

诀窍是什么?

(我可能会通过某些模板的专业帮手结构过程中使用的类型,间接得到这个信息:

template <typename PIXEL> struct types_for 
    {}; 
template <> struct types_for<boost::gil::gray8_pixel_t> 
    {typedef unsigned char channel_type;}; 
template <> struct types_for<boost::gil::gray16_pixel_t> 
    {typedef unsigned short channel_type;}; 

,但肯定GIL必须已经提供等同的东西,如果我能找到它... )

回答

1

啊哈...这似乎这样的伎俩:

typename boost::gil::channel_type<PIXEL>::type