I have a class templated on <PIXEL>
, assumed to be one of boost::gil
's pixel types (for now, only either gray8_pixel_t
or gray16_pixel_t
, and I only expect to support homogeneous pixel types e.g rgb8_pixel_t
in future).
The class needs to get hold of unsigned char
or unsigned short
as appropriate to the pixel type; I assume this is buried somehwere in the pixel class, but none of PIXEL::value_type
, PIXEL::channel_type
or PIXEL::channel_type::value type
seems to be what I want.
What's the trick ?
(I could of course use type-indirection via some template-specialized helper structs to get this info:
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;};
but surely GIL must provide something equivalent already, if I could just find it...)