[trunk] fixed pnmtoimage for odd pgm files (fixes issue 294)
This commit is contained in:
parent
0ba5d15b58
commit
13bcb63b73
|
@ -1665,7 +1665,6 @@ static char *skip_idf(char *start, char out_idf[256])
|
||||||
|
|
||||||
static void read_pnm_header(FILE *reader, struct pnm_header *ph)
|
static void read_pnm_header(FILE *reader, struct pnm_header *ph)
|
||||||
{
|
{
|
||||||
char *s;
|
|
||||||
int format, have_wh, end, ttype;
|
int format, have_wh, end, ttype;
|
||||||
char idf[256], type[256];
|
char idf[256], type[256];
|
||||||
char line[256];
|
char line[256];
|
||||||
|
@ -1691,6 +1690,8 @@ static void read_pnm_header(FILE *reader, struct pnm_header *ph)
|
||||||
|
|
||||||
while(fgets(line, 250, reader))
|
while(fgets(line, 250, reader))
|
||||||
{
|
{
|
||||||
|
char *s;
|
||||||
|
|
||||||
if(*line == '#') continue;
|
if(*line == '#') continue;
|
||||||
|
|
||||||
s = line;
|
s = line;
|
||||||
|
@ -1775,6 +1776,17 @@ static void read_pnm_header(FILE *reader, struct pnm_header *ph)
|
||||||
|
|
||||||
if(format == 1 || format == 4) break;
|
if(format == 1 || format == 4) break;
|
||||||
|
|
||||||
|
if(format == 2 || format == 3 || format == 5 || format == 6)
|
||||||
|
{
|
||||||
|
if (skip_int(s, &ph->maxval) != NULL) {
|
||||||
|
if(ph->maxval > 65535) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if(format == 2 || format == 3 || format == 5 || format == 6)
|
if(format == 2 || format == 3 || format == 5 || format == 6)
|
||||||
|
|
Loading…
Reference in New Issue