26 #ifndef MLN_IO_PNM_LOAD_HEADER_HH
27 # define MLN_IO_PNM_LOAD_HEADER_HH
48 # ifndef MLN_INCLUDE_ONLY
58 if (istr.get() !=
'P' )
60 type =
static_cast<char>(istr.get());
62 if (type < '1' || type >
'6')
64 if (istr.get() !=
'\n')
68 while (istr.peek() ==
'#')
71 std::getline(istr, line);
75 istr >> ncols >>
nrows;
76 if (nrows <= 0 || ncols <= 0)
80 if (istr.get() !=
'\n')
82 if (type !=
'1' && type !=
'4')
85 if (istr.get() !=
'\n')
93 std::cerr <<
"error: badly formed header!";
103 int& nrows,
int& ncols,
104 unsigned int& maxval)
107 if (! (type == ascii || type == raw))
109 std::cerr <<
"error: bad pnm type; "
110 <<
"expected P" << ascii
112 <<
", get P" << type <<
"!";
121 int& nrows,
int& ncols)
125 nrows, ncols, maxval);
128 # endif // ! MLN_INCLUDE_ONLY
137 #endif // ! MLN_IO_PNM_LOAD_HEADER_HH