27 #ifndef MLN_IO_PBM_LOAD_HH
28 # define MLN_IO_PBM_LOAD_HH
40 # include <mln/core/image/image2d.hh>
41 # include <mln/core/image/image3d.hh>
42 # include <mln/io/pnm/load_header.hh>
63 void load(image2d<bool>& ima,
77 # ifndef MLN_INCLUDE_ONLY
85 void load_ascii(std::ifstream& file, I& ima)
87 mln_fwd_piter(I)
p(ima.domain());
93 mln_assertion(value ==
'0' || value ==
'1');
94 ima(p) = (value ==
'0');
100 template <
typename I>
102 void load_raw_2d(std::ifstream& file, I& ima)
105 typedef mln_value(I) V;
120 file.read((
char*)(&c), 1);
122 c =
static_cast<char>(c * 2);
135 mln_trace(
"mln::io::pbm::load");
136 std::ifstream file(filename.c_str());
139 std::cerr <<
"error: file '" << filename
147 image2d<bool> ima(nrows, ncols);
149 internal::load_raw_2d(file, ima);
152 internal::load_ascii(file, ima);
160 void load(image2d<bool>& ima,
161 const std::string& filename)
163 ima =
load(filename);
167 # endif // ! MLN_INCLUDE_ONLY
176 #endif // ! MLN_IO_PBM_LOAD_HH