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-07-04 11:50:33


Nathan, it just occurred to me. Why don't you use bit_aligned images
for your sample code below? You min and max are the same.

typedef bit_aligned_image1_type< 12, gray_layout_t >::type gray12_image_t;
typedef bit_aligned_image1_type< 14, gray_layout_t >::type gray14_image_t;

Regards,
Christian

On Wed, Jun 23, 2010 at 2:18 PM, Nathan Crookston
<nathan.crookston_at_[hidden]> wrote:
> Hi Christian,
>
> On Wed, Jun 23, 2010 at 10:42 AM, Christian Henning <chhenning_at_[hidden]> wrote:
>>> The only difference between what you suggested and what I'm posting is
>>> the addition of some explicit construction calls:
>>
>> I'm sorry I cannot make out your addition of some explicit constructor
>> calls. Did you send the correct patch snippet? Could we just post the
>> code without the patch syntax? I don't use patch.
>>
>
> Sorry, I could have been clearer.  The original code used only
> explicit construction calls.  Your suggested code replaced them with
> static_cast (which would work great if they were casting to the
> correct type instead of just an integral type).  I found that both
> were necessary to suppress warnings.  Here's the new code:
>
> // Both source and destination are unsigned integral channels,
> // the dst max value is less than (or equal to) the src max value,
> // and the src max value is not divisible by the dst max value
> 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 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 src_integer_t div2 = static_cast<src_integer_t>(div/2);
>        return DstChannelV(static_cast<dst_integer_t>((src + div2) / div));
>    }
> };
>
> } // namespace detail
>
> /////////////////////////////////////////////////////
> ///  bits32f conversion
> /////////////////////////////////////////////////////
>
> 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 DstChannelV(static_cast<dst_integer_t>(x*channel_traits<DstChannelV>::max_value()+0.5f));
>    }
> }
>
> Thanks for your help on this, and for you work on the library.  Good
> luck on the IO review!
>
> 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