
Christian, First off, I think the semantics of color_convert already handle this. That function maps the min and max value of the source channel type to the min and max value of the target channel type. 1. I think you can use type traits. boost::is_integral<T>::value tells you if it is an integer data, and boost::is_signed tells you whether or not it is -- well, signed. Just #include<boost/type_traits.hpp>. 2. I think you can write a multifunction and pass it into boost::gil::static_for_each. Create a class and make a templatized member function operator()(T1 src, T2& dst) that does the special conversion you want. Use enable_if and disable_if from <boost/utility.hpp> to specialize the member function. 3. the xxx8_image_t is not a real type -- it is a typedef from image<pixel<uint8, xxx_layout_t>, false>. John Femiani. -----Original Message----- From: boost-bounces@lists.boost.org [mailto:boost-bounces@lists.boost.org] On Behalf Of Christian Henning Sent: Monday, April 23, 2007 8:38 AM To: boost@lists.boost.org Subject: [boost] [gil] Ideas to make my extension more generic? Hi there, in the course of getting more familiar with gil 2.0 I started writing a new extension for downsampling (don't if that's the right term) an source image to its unsigned 8 bit counterpart. You would use such an extension when trying to save an image that is using more than 8 bit per channel, e.g. rgb32_image_t. Some file formats only take unsigned 8bit per channel. Attached there is the code I have so far. But there are still some areas where my extension isn't generic enough or even the algorithm fails due to my own short comings. Here are some questions I have: 1. How do I figure out if the src channel type is signed? If it is I would like to add half the value range to all channels and pixels. 2. When dealing with heterogeneous pixel types how can I initializes them generically? 3. How do I compute the unsigned 8bit image type of the src image type? I'm looking for xxx8_image_t. Thanks ahead. Any ideas or suggestions are welcome. Christian