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
Hi Christian,
On Wed, Jun 23, 2010 at 10:42 AM, Christian Henning
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
struct channel_converter_unsigned_integral_nondivisible { 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
(div/2); return DstChannelV(static_cast ((src + div2) / div)); } }; } // namespace detail
///////////////////////////////////////////////////// /// bits32f conversion /////////////////////////////////////////////////////
template <typename DstChannelV> struct channel_converter_unsigned
: public std::unary_function { DstChannelV operator()(bits32f x) const { typedef typename detail::unsigned_integral_max_value<DstChannelV>::value_type dst_integer_t; return DstChannelV(static_cast (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@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users