2857: Add a saving routine for rgb8 (color) 2-complex images.

* mln/io/off/save.hh (io::off::save(const rgb8_2complex_image3df&, const std::string&)): New function. (io::off::internal::rgb8_off_saver): New functor. --- milena/ChangeLog | 9 +++++++++ milena/mln/io/off/save.hh | 39 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+), 0 deletions(-) diff --git a/milena/ChangeLog b/milena/ChangeLog index 3706c51..c412779 100644 --- a/milena/ChangeLog +++ b/milena/ChangeLog @@ -1,5 +1,14 @@ 2008-11-12 Roland Levillain <roland@lrde.epita.fr> + Add a saving routine for rgb8 (color) 2-complex images. + + * mln/io/off/save.hh + (io::off::save(const rgb8_2complex_image3df&, const std::string&)): + New function. + (io::off::internal::rgb8_off_saver): New functor. + +2008-11-12 Roland Levillain <roland@lrde.epita.fr> + Add a saving routine for floating-point value 2-complex images. * mln/io/off/save.hh diff --git a/milena/mln/io/off/save.hh b/milena/mln/io/off/save.hh index e6582cc..40f2e5a 100644 --- a/milena/mln/io/off/save.hh +++ b/milena/mln/io/off/save.hh @@ -87,6 +87,16 @@ namespace mln void save(const float_2complex_image3df& ima, const std::string& filename); + /** \brief Save a 3x8-bit RGB (color) OFF image into a complex image. + + \param[in] ima The image to save. + \param[in] filename The name of the file where to save the image. + + Only data is attached to 2-faces is saved; the OFF file + cannot store data attached to faces of other dimensions. */ + void save(const rgb8_2complex_image3df& ima, + const std::string& filename); + namespace internal { @@ -136,6 +146,14 @@ namespace mln void write_face_data(std::ostream& ostr, const value& v) const; }; + + struct rgb8_off_saver + : public off_saver< rgb8_2complex_image3df, rgb8_off_saver > + { + /// \brief Save face data. + void write_face_data(std::ostream& ostr, const value& v) const; + }; + } // end of namespace mln::io::off::internal @@ -170,6 +188,14 @@ namespace mln trace::exiting("mln::io::off::save"); } + void + save(const rgb8_2complex_image3df& ima, const std::string& filename) + { + trace::entering("mln::io::off::save"); + internal::rgb8_off_saver()(ima, filename); + trace::exiting("mln::io::off::save"); + } + /*-------------------------. | Actual implementations. | @@ -399,6 +425,19 @@ namespace mln ostr << ' ' << v << ' ' << v << ' ' << v << ' ' << 1.0f << std::endl; } + + void + rgb8_off_saver::write_face_data(std::ostream& ostr, + const value& v) const + { + /* RGBA color. + + Each channel (R, G, B) of the color V is an integer in + the range 0..255. A fourth channel, A, controls the + transparency. */ + ostr << ' ' << v.red() << ' ' << v.green() << ' ' << v.blue() + << ' ' << 1.0f << std::endl; + } /* \} */ } // end of namespace mln::io::off::internal -- 1.6.0.1
participants (1)
-
Roland Levillain