2010-03-30 40 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