milena r1560: make save pgm work on graylevels. document pnm::save

URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena ChangeLog: 2007-11-28 Matthieu Garrigues <garrigues@lrde.epita.fr> make save pgm work on graylevels. document pnm::save. * mln/io/pgm/save.hh: Disable type checking in pgm::save to allow to save graylevel images. * mln/io/pnm/save.hh: Documentation. * mln/io/pnm/save_header.hh: graylevel compatibility. --- pgm/save.hh | 10 ++++++---- pnm/save.hh | 9 ++++++++- pnm/save_header.hh | 3 +-- 3 files changed, 15 insertions(+), 7 deletions(-) Index: trunk/milena/mln/io/pgm/save.hh =================================================================== --- trunk/milena/mln/io/pgm/save.hh (revision 1559) +++ trunk/milena/mln/io/pgm/save.hh (revision 1560) @@ -72,10 +72,12 @@ template <typename I> void save(const Image<I>& ima, const std::string& filename) { - mln::metal::or_< - mln::metal::templated_by<mln_value(I), value::int_u >, - mln::metal::templated_by<mln_value(I), value::int_u_sat > - >::check(); + // FIXME : this is to restrictive. Check if I is compatible with PGM. + // mln::metal::or_< + // mln::metal::templated_by<mln_value(I), value::int_u >, + // mln::metal::templated_by<mln_value(I), value::int_u_sat > + // >::check(); + io::pnm::save(PGM, exact(ima), filename); } Index: trunk/milena/mln/io/pnm/save_header.hh =================================================================== --- trunk/milena/mln/io/pnm/save_header.hh (revision 1559) +++ trunk/milena/mln/io/pnm/save_header.hh (revision 1560) @@ -57,8 +57,7 @@ template <typename V> void save_max_val(V&, std::ofstream& file) { - if (mln_max(V) > 1) - file << unsigned(mln_max(V)) << std::endl; + file << mln_max(V) << std::endl; } void save_max_val(bool&, std::ofstream& file) Index: trunk/milena/mln/io/pnm/save.hh =================================================================== --- trunk/milena/mln/io/pnm/save.hh (revision 1559) +++ trunk/milena/mln/io/pnm/save.hh (revision 1560) @@ -64,7 +64,14 @@ namespace pnm { - // FIXME: Doc. + /*! Save a milena image as a pnm image. + * + * \param[in] type The type of the image to save (can be PPM, + * PGM, PBM). + * \param[in] ima_ The image to save. + * \param[in,out] filename the destination. + */ + template <typename I> void save(const int type, const Image<I>& ima_, const std::string& filename);
participants (1)
-
Matthieu Garrigues