Boost logo

Boost Users :

Subject: Re: [Boost-users] [GIL] Warnings when compiling items in channel_algorithms.hpp
From: Christian Henning (chhenning_at_[hidden])
Date: 2010-06-18 21:06:18


Hi Nathan, I have reviewed your patch and it looks good. Thanks for
your work. I got rid of the base_channel meta_function and just
introduced a dst_integer_t typedef instead. Please review below:

template <typename SrcChannelV, typename DstChannelV, bool CannotFit>
struct channel_converter_unsigned_integral_nondivisible<SrcChannelV,DstChannelV,false,CannotFit>
{
    DstChannelV operator()(SrcChannelV src) const {

        typedef typename detail::unsigned_integral_max_value<
SrcChannelV >::value_type src_integer_t;
        typedef typename detail::unsigned_integral_max_value<
DstChannelV >::value_type dst_integer_t;

        //typedef typename
unsigned_integral_max_value<SrcChannelV>::value_type integer_t;

        static const double div =
unsigned_integral_max_value<SrcChannelV>::value
                                /
double(unsigned_integral_max_value<DstChannelV>::value);

        static const src_integer_t div2 = static_cast< src_integer_t
>( div / 2 );

        return static_cast< dst_integer_t >(( static_cast< double >(
src + div2 ) / div ));
    }
};

template <typename DstChannelV> struct
channel_converter_unsigned<bits32f,DstChannelV> : public
std::unary_function<bits32f,DstChannelV> {
    DstChannelV operator()(bits32f x) const
    {
        typedef typename detail::unsigned_integral_max_value<
DstChannelV >::value_type dst_integer_t;
        return static_cast< dst_integer_t
>(x*channel_traits<DstChannelV>::max_value()+0.5f);
    }
};

Regards,
Christian


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net