Commit c3d187ed authored by Guillaume Lazzara's avatar Guillaume Lazzara
Browse files

Fix more warnings in Milena.

	* mln/convert/impl/from_float_to_value.hh: Add an overload for
	short int.

	* mln/io/fld/load.hh: Use convert::from_to.

	* mln/io/fld/max_components.hh: Explicitly cast values to unsigned.
parent a903e8da
2010-08-12 Guillaume Lazzara <z@lrde.epita.fr>
Fix more warnings in Milena.
* mln/convert/impl/from_float_to_value.hh: Add an overload for
short int.
* mln/io/fld/load.hh: Use convert::from_to.
* mln/io/fld/max_components.hh: Explicitly cast values to unsigned.
2010-08-11 Guillaume Lazzara <z@lrde.epita.fr>
 
Fix more tests in Milena.
......@@ -143,6 +143,16 @@ namespace mln
to = math::round<int>()(from);
}
// float-> short
inline
void
from_to_(const float& from,
short& to)
{
to = math::round<short>()(from);
}
} // end of namespace mln::convert::over_load
# endif // ! MLN_INCLUDE_ONLY
......
// Copyright (C) 2008, 2009 EPITA Research and Development Laboratory (LRDE)
// Copyright (C) 2008, 2009, 2010 EPITA Research and Development
// Laboratory (LRDE)
//
// This file is part of Olena.
//
......@@ -43,6 +44,9 @@
///
/// FIXME: pnm::load uses special implementation if sizeof(int_u8) != 1 ?? what ??
# include <fstream>
# include <iostream>
# include <mln/core/concept/image.hh>
# include <mln/io/fld/header.hh>
# include <mln/io/fld/load_header.hh>
......@@ -54,8 +58,7 @@
# include <mln/geom/nsites.hh>
# include <fstream>
# include <iostream>
# include <mln/convert/from_to.hh>
namespace mln
{
......@@ -220,8 +223,8 @@ namespace mln
box<mln_site(I)> bbox;
for (int i = 0; i < hder.ndim; ++i)
{
bbox.pmin()[i] = hder.min_ext[i];
bbox.pmax()[i] = hder.max_ext[i];
convert::from_to(hder.min_ext[i], bbox.pmin()[i]);
convert::from_to(hder.max_ext[i], bbox.pmax()[i]);
}
ima.init_(bbox);
......
// Copyright (C) 2008, 2009 EPITA Research and Development Laboratory (LRDE)
// Copyright (C) 2008, 2009, 2010 EPITA Research and Development
// Laboratory (LRDE)
//
// This file is part of Olena.
//
......@@ -26,6 +27,11 @@
#ifndef MLN_IO_FLD_MAX_COMPONENTS_HH
# define MLN_IO_FLD_MAX_COMPONENTS_HH
/// \file
///
/// \fixme Don't we want to change the return type 'unsigned' to a
/// larger type or make it templated?
# include <mln/algebra/vec.hh>
# include <mln/value/rgb.hh>
# include <mln/io/fld/header.hh>
......@@ -41,53 +47,53 @@ namespace mln
template <typename V>
inline
unsigned int max_component(const V&);
unsigned max_component(const V&);
template <unsigned n, typename V>
inline
unsigned int max_component(const algebra::vec<n, V>& v);
unsigned max_component(const algebra::vec<n, V>& v);
template <unsigned n>
inline
unsigned int max_component(const value::rgb<n>&);
unsigned max_component(const value::rgb<n>&);
inline
unsigned int max_component(const fld::data_type::E& t);
unsigned max_component(const fld::data_type::E& t);
# ifndef MLN_INCLUDE_ONLY
template <typename V>
inline
unsigned int max_component(const V&)
unsigned max_component(const V&)
{
return mln_max(V);
return unsigned(mln_max(V));
}
template <unsigned n, typename V>
inline
unsigned int max_component(const algebra::vec<n, V>& v)
unsigned max_component(const algebra::vec<n, V>& v)
{
return mln_max(V);
return unsigned(mln_max(V));
}
template <unsigned n>
inline
unsigned int max_component(const value::rgb<n>&)
unsigned max_component(const value::rgb<n>&)
{
return mln_max(mln::value::int_u<n>);
}
inline
unsigned int max_component(const fld::data_type::E& t)
unsigned max_component(const fld::data_type::E& t)
{
switch (t)
{
case data_type::BYTE: return mln_max(unsigned char);
case data_type::SHORT: return mln_max(unsigned short);
case data_type::INTEGER: return mln_max(unsigned);
case data_type::FLOAT: return mln_max(float);
case data_type::DOUBLE: return mln_max(double);
case data_type::FLOAT: return unsigned(mln_max(float));
case data_type::DOUBLE: return unsigned(mln_max(double));
default: return 0;
}
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment