36 FILE *f = fopen(path,
"rb");
48 if (fgets(tmp,
sizeof(tmp), f) == NULL)
57 if (pnm->
format == -1 && tmp[0]==
'P') {
64 while (nparams < 3 && *p!=0) {
69 if (*p < '0' || *p >
'9')
73 while (*p >=
'0' && *p <=
'9') {
74 acc = acc*10 + *p -
'0';
78 params[nparams++] = acc;
83 pnm->
width = params[0];
94 size_t len = fread(pnm->
buf, 1, pnm->
buflen, f);
105 else if (pnm->
max == 65535)
111 size_t len = fread(pnm->
buf, 1, pnm->
buflen, f);
122 else if (pnm->
max == 65535)
128 size_t len = fread(pnm->
buf, 1, pnm->
buflen, f);
#define PNM_FORMAT_BINARY
pnm_t * pnm_create_from_file(const char *path)
void pnm_destroy(pnm_t *pnm)