|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r64598 - trunk/boost/gil
From: chhenning_at_[hidden]
Date: 2010-08-04 12:00:20
Author: chhenning
Date: 2010-08-04 11:57:59 EDT (Wed, 04 Aug 2010)
New Revision: 64598
URL: http://svn.boost.org/trac/boost/changeset/64598
Log:
Code changes to suppress some compiler warnings when using scoped_channel_value.
Text files modified:
trunk/boost/gil/channel_algorithm.hpp | 20 ++++++++++++++------
1 files changed, 14 insertions(+), 6 deletions(-)
Modified: trunk/boost/gil/channel_algorithm.hpp
==============================================================================
--- trunk/boost/gil/channel_algorithm.hpp (original)
+++ trunk/boost/gil/channel_algorithm.hpp 2010-08-04 11:57:59 EDT (Wed, 04 Aug 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