* mln/convert/impl/from_value_to_value.hh: Disable dispatch and
rely on from_to().
* mln/value/rgb.hh: Add a from_to_() overload to handle conversion
from rgb<n> to rgb<m>.
---
milena/ChangeLog | 10 +++++
milena/mln/convert/impl/from_value_to_value.hh | 44 +++++++++++++-----------
milena/mln/value/rgb.hh | 26 ++++++++++++--
3 files changed, 57 insertions(+), 23 deletions(-)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index 4bce1ed..14d36de 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,3 +1,13 @@
+2013-04-24 Guillaume Lazzara <z(a)lrde.epita.fr>
+
+ Relax conversion dispatch.
+
+ * mln/convert/impl/from_value_to_value.hh: Disable dispatch and
+ rely on from_to().
+
+ * mln/value/rgb.hh: Add a from_to_() overload to handle conversion
+ from rgb<n> to rgb<m>.
+
2013-04-23 Guillaume Lazzara <z(a)lrde.epita.fr>
* tests/io/magick/save.cc: Kill compilation warnings.
diff --git a/milena/mln/convert/impl/from_value_to_value.hh
b/milena/mln/convert/impl/from_value_to_value.hh
index fea91a3..9c93e5a 100644
--- a/milena/mln/convert/impl/from_value_to_value.hh
+++ b/milena/mln/convert/impl/from_value_to_value.hh
@@ -1,4 +1,4 @@
-// Copyright (C) 2008, 2009, 2012 EPITA Research and Development
+// Copyright (C) 2008, 2009, 2012, 2013 EPITA Research and Development
// Laboratory (LRDE)
//
// This file is part of Olena.
@@ -65,25 +65,29 @@ namespace mln
# ifndef MLN_INCLUDE_ONLY
- // Case 1:
-
- template <typename V, typename W>
- void
- from_value_to_value_(const mln::value::Vectorial<V>& from,
- mln::value::Vectorial<W>& to)
- {
- exact(to) = exact(from).to_equiv();
- }
-
- // Case 2:
-
- template <typename V, typename W>
- void
- from_value_to_value_(const mln::value::Scalar<V>& from,
- mln::value::Scalar<W>& to)
- {
- exact(to) = exact(from).to_equiv();
- }
+ // We want to disable this code since it prevents types of
+ // different quantification to rely on from_to_ overload and
+ // handle specific conversions. (ex: rgb16 towards rgb8)
+
+ // // Case 1:
+
+ // template <typename V, typename W>
+ // void
+ // from_value_to_value_(const mln::value::Vectorial<V>& from,
+ // mln::value::Vectorial<W>& to)
+ // {
+ // exact(to) = exact(from).to_equiv();
+ // }
+
+ // // Case 2:
+
+ // template <typename V, typename W>
+ // void
+ // from_value_to_value_(const mln::value::Scalar<V>& from,
+ // mln::value::Scalar<W>& to)
+ // {
+ // exact(to) = exact(from).to_equiv();
+ // }
template <typename V, typename W>
inline
diff --git a/milena/mln/value/rgb.hh b/milena/mln/value/rgb.hh
index b29b479..24bf438 100644
--- a/milena/mln/value/rgb.hh
+++ b/milena/mln/value/rgb.hh
@@ -362,7 +362,7 @@ namespace mln
/// \internal Conversion: rgb -> bool.
template <unsigned m>
- void from_to_(const value::rgb<m>& from, bool& to);
+ void from_to_(const rgb<m>& from, bool& to);
/// \internal Conversion: rgb to hsl_
void
@@ -374,7 +374,16 @@ namespace mln
/// \internal Conversion: bool -> rgb.
template <unsigned m>
- void from_to_(bool from, value::rgb<m>& to);
+ void from_to_(bool from, rgb<m>& to);
+
+ /*!
+ \brief Conversion: rgb -> rgb.
+ \pre n <= m
+ \ingroup fromto
+ */
+ template <unsigned n, unsigned m>
+ void
+ from_to_(const rgb<n>& from, rgb<m>& to);
} // end of namespace mln::value
@@ -762,7 +771,7 @@ namespace mln
template <unsigned m>
void
- from_to_(bool from, mln::value::rgb<m>& to)
+ from_to_(bool from, rgb<m>& to)
{
static mln::literal::white_t* white_ = 0;
static mln::literal::black_t* black_ = 0;
@@ -775,6 +784,17 @@ namespace mln
to = *black_;
}
+ template <unsigned n, unsigned m>
+ void
+ from_to_(const rgb<n>& from, rgb<m>& to)
+ {
+ mln_assertion(n <= m);
+ to.red() = from.red();
+ to.green() = from.green();
+ to.blue() = from.blue();
+ }
+
+
} // end of namespace mln::value
} // end of namespace mln
--
1.7.2.5