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-08-04 12:11:39


Nathan, I have updated the boost trunk with your patch. I mean the
updated one we both agreed on, I believe. The patch wont make into
boost 1.45. But should appear in the following versions. I just need
to remember to update boost_release branch once the current release is
done. ;-)

Thanks for your help,
Christian

On Mon, Jun 21, 2010 at 6:11 PM, Nathan Crookston
<nathan.crookston_at_[hidden]> wrote:
> Hi Christian,
>
> Thanks for looking over my patch.  With a minor amount of tweaking of
> your code and my sample program, I was able to compile both my sample
> program and my reasonably extensive work code.
>
> The only difference between what you suggested and what I'm posting is
> the addition of some explicit construction calls:
>
> Index: channel_algorithm.hpp
> ===================================================================
> --- channel_algorithm.hpp (revision 63088)
> +++ channel_algorithm.hpp (working copy)
> @@ -250,11 +250,12 @@
>  template <typename SrcChannelV, typename DstChannelV, bool CannotFit>
>  struct channel_converter_unsigned_integral_nondivisible<SrcChannelV,DstChannelV,false,CannotFit>
> {
>     DstChannelV operator()(SrcChannelV src) const {
> -        typedef typename
> unsigned_integral_max_value<SrcChannelV>::value_type integer_t;
> +        typedef typename
> unsigned_integral_max_value<SrcChannelV>::value_type src_integer_t;
> +        typedef typename
> unsigned_integral_max_value<DstChannelV>::value_type dst_integer_t;
>
>         static const double div =
> unsigned_integral_max_value<SrcChannelV>::value /
> double(unsigned_integral_max_value<DstChannelV>::value);
> -        static const integer_t div2 = integer_t(div/2);
> -        return DstChannelV((src + div2) / div);
> +        static const src_integer_t div2 = static_cast<src_integer_t>(div/2);
> +        return DstChannelV(static_cast<dst_integer_t>((src + div2) / div));
>     }
>  };
>
> @@ -265,7 +266,10 @@
>  /////////////////////////////////////////////////////
>
>  template <typename DstChannelV> struct
> channel_converter_unsigned<bits32f,DstChannelV> : public
> std::unary_function<bits32f,DstChannelV> {
> -    DstChannelV   operator()(bits32f x) const { return
> DstChannelV(x*channel_traits<DstChannelV>::max_value()+0.5f); }
> +    DstChannelV   operator()(bits32f x) const {
> +      typedef typename
> detail::unsigned_integral_max_value<DstChannelV>::value_type
> dst_integer_t;
> +      return DstChannelV(static_cast<dst_integer_t>(x*channel_traits<DstChannelV>::max_value()+0.5f));
> +    }
>  };
>
>  template <typename SrcChannelV> struct
> channel_converter_unsigned<SrcChannelV,bits32f> : public
> std::unary_function<SrcChannelV,bits32f> {
>
> My sample program required the following modification:
>
> FROM:
>  template <>
>   struct unsigned_integral_max_value<bits14>
>     : public mpl::integral_c<uint32_t,bits14_max_val> {};
> TO:
>
>  template <>
>   struct unsigned_integral_max_value<bits14>
>     : public mpl::integral_c<uint16_t,bits14_max_val> {};
>
> This makes the specialization of unsigned_integral_max_value different
> from the others in channel_algorithm.hpp -- they use uint32_t and
> uintmax_t, even for 8 and 16 bit types.  This appears to be
> intentional, as changing them to match their arguments results in a
> compile error (and many tricky const initialization problems).  This
> makes me wonder if the unsigned_integral_max_value<>::value_type was
> intended to be used that way.
>
> I wonder if there's value in a metafunction that returns the type we
> expect to construct our channel from (similar to the suggested
> base_channel).  This isn't a critical issue for me, however, as your
> suggestions are working well for me now.
>
> Thanks!
> Nate
> _______________________________________________
> Boost-users mailing list
> Boost-users_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/boost-users
>


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