|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r65908 - branches/release/boost/gil
From: chhenning_at_[hidden]
Date: 2010-10-11 11:51:57
Author: chhenning
Date: 2010-10-11 11:51:55 EDT (Mon, 11 Oct 2010)
New Revision: 65908
URL: http://svn.boost.org/trac/boost/changeset/65908
Log:
Code changes to suppress some compiler warnings when using scoped_channel_value.
Text files modified:
branches/release/boost/gil/channel_algorithm.hpp | 20 ++++++++++++++------
1 files changed, 14 insertions(+), 6 deletions(-)
Modified: branches/release/boost/gil/channel_algorithm.hpp
==============================================================================
--- branches/release/boost/gil/channel_algorithm.hpp (original)
+++ branches/release/boost/gil/channel_algorithm.hpp 2010-10-11 11:51:55 EDT (Mon, 11 Oct 2010)
@@ -243,18 +243,22 @@
}
};
-
// 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 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);
+ 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;
+
+ static const double div = unsigned_integral_max_value<SrcChannelV>::value
+ / static_cast< double >( unsigned_integral_max_value<DstChannelV>::value );
+
+ static const src_integer_t div2 = static_cast< src_integer_t >( div / 2.0 );
+
+ return DstChannelV( static_cast< dst_integer_t >(( static_cast< double >( src + div2 ) / div )));
}
};
@@ -265,7 +269,11 @@
/////////////////////////////////////////////////////
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> {
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk