27 #ifndef MLN_IO_PFM_LOAD_HH
28 # define MLN_IO_PFM_LOAD_HH
38 # include <mln/core/image/image2d.hh>
39 # include <mln/value/int_u8.hh>
59 void load(image2d<float>& ima,
72 # ifndef MLN_INCLUDE_ONLY
80 std::cerr <<
" aborting." << std::endl;
85 bool read_pfm_header(std::istream& file,
95 if (file.get() !=
'\n')
103 if (file.get() !=
'\n')
111 std::cerr <<
"error: badly formed header!"
120 template <
typename I>
122 void load_raw_2d(std::ifstream& file, I& ima)
131 ncols = geom::ncols(ima);
134 file.read((
char*)(&(ima(p))),
135 sizeof(
float) * ncols);
145 mln_trace(
"mln::io::pfm::load");
147 std::ifstream file(filename.c_str());
150 std::cerr <<
"error: file '" << filename
155 internal::read_pfm_header(file, nrows, ncols);
157 image2d<float> ima(nrows, ncols);
158 internal::load_raw_2d(file, ima);
166 void load(image2d<float>& ima,
167 const std::string& filename)
169 ima =
load(filename);
172 # endif // ! MLN_INCLUDE_ONLY
181 #endif // ! MLN_IO_PFM_LOAD_HH