00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029 #ifndef DOC_TOOLS_SAMPLE_UTILS_HH
00030 # define DOC_TOOLS_SAMPLE_UTILS_HH
00031
00032 # include <mln/core/image/image2d.hh>
00033 # include <mln/io/pbm/all.hh>
00034 # include <mln/io/pgm/all.hh>
00035 # include <mln/io/ppm/all.hh>
00036
00037 # include "doc/tools/data.hh"
00038
00039 namespace doc
00040 {
00041
00042 inline
00043 std::string
00044 file(const std::string& name, const std::string& extension)
00045 {
00046 static int file_id = 1;
00047
00048 std::ostringstream os;
00049 os << MLN_DOC_DIR "/figures/"
00050 << name
00051 << "-"
00052 << file_id++
00053 << "."
00054 << extension;
00055 return os.str();
00056 }
00057
00058 template <typename I>
00059 inline
00060 void
00061 ppmsave(const mln::Image<I>& ima, const std::string& name)
00062 {
00063 mln::io::ppm::save(ima, file(name, "ppm"));
00064 }
00065
00066 template <typename I>
00067 inline
00068 void
00069 pbmsave(const mln::Image<I>& ima, const std::string& name)
00070 {
00071 mln::io::pbm::save(ima, file(name, "pbm"));
00072 }
00073
00074 template <typename I>
00075 inline
00076 void
00077 pgmsave(const mln::Image<I>& ima, const std::string& name)
00078 {
00079 mln::io::pgm::save(ima, file(name, "pgm"));
00080 }
00081
00082 inline
00083 void
00084 begin_output()
00085 {
00086 std::cout << "// \\{" << std::endl;
00087 }
00088
00089 inline
00090 void
00091 end_output()
00092 {
00093 std::cout << "// \\}" << std::endl;
00094 }
00095
00096 }
00097
00098 #endif // ! DOC_TOOLS_SAMPLE_UTILS_HH
00099