* mln/io/off/save.hh
(io::off::save(const int_u8_2complex_image3df&, const std::string&)):
New function.
(io::off::internal::int_u8_off_saver): New functor.
---
milena/ChangeLog | 9 +++++++++
milena/mln/io/off/save.hh | 42 ++++++++++++++++++++++++++++++++++++++++++
2 files changed, 51 insertions(+), 0 deletions(-)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index 0fb9951..1a0b0a0 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,5 +1,14 @@
2008-11-12 Roland Levillain <roland(a)lrde.epita.fr>
+ Add a saving routine for int_u8 2-complex images.
+
+ * mln/io/off/save.hh
+ (io::off::save(const int_u8_2complex_image3df&, const std::string&)):
+ New function.
+ (io::off::internal::int_u8_off_saver): New functor.
+
+2008-11-12 Roland Levillain <roland(a)lrde.epita.fr>
+
Introduce a factoring functor to save OFF image files.
* mln/io/off/save.hh (mln::io::off::internal::off_saver): New.
diff --git a/milena/mln/io/off/save.hh b/milena/mln/io/off/save.hh
index a3fde3a..604281e 100644
--- a/milena/mln/io/off/save.hh
+++ b/milena/mln/io/off/save.hh
@@ -66,6 +66,16 @@ namespace mln
void save(const bin_2complex_image3df& ima,
const std::string& filename);
+ /** \brief Save an 8-bit grey-level 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 int_u8_2complex_image3df& ima,
+ const std::string& filename);
+
namespace internal
{
@@ -96,6 +106,14 @@ namespace mln
void write_face_data(std::ostream& ostr, const value& v) const;
};
+
+ struct int_u8_off_saver
+ : public off_saver< int_u8_2complex_image3df, int_u8_off_saver >
+ {
+ /// \brief Save face data.
+ void write_face_data(std::ostream& ostr, const value& v) const;
+ };
+
} // end of namespace mln::io::off::internal
@@ -114,6 +132,14 @@ namespace mln
trace::exiting("mln::io::off::save");
}
+ void
+ save(const int_u8_2complex_image3df& ima, const std::string& filename)
+ {
+ trace::entering("mln::io::off::save");
+ internal::int_u8_off_saver()(ima, filename);
+ trace::exiting("mln::io::off::save");
+ }
+
/*-------------------------.
| Actual implementations. |
@@ -306,6 +332,22 @@ namespace mln
{
// Do nothing (no data associated to faces).
}
+
+ void
+ int_u8_off_saver::write_face_data(std::ostream& ostr,
+ const value& v) const
+ {
+ /* Using RGBA colors to represent an 8-bit integer value.
+
+ Each channel (R, G, B) of the color V is an integer in
+ the range 0..255. A fourth channel, A, controls the
+ transparency.
+
+ We just set the same value for each channel, as the OFF
+ file format does not support gray-level values as-is. */
+ ostr << ' ' << v << ' ' << v << '
' << v
+ << ' ' << 1.0f << std::endl;
+ }
/* \} */
} // end of namespace mln::io::off::internal
--
1.6.0.1
Show replies by date