fixed a problem in convert.c when multiple comments
This commit is contained in:
parent
ec2b3b3b3f
commit
2f75846baf
|
@ -6,6 +6,7 @@ What's New for OpenJPEG
|
|||
+ : added
|
||||
|
||||
January 25, 2006
|
||||
* [Antonin Descampe] fixed a problem in convert.c when multiple comments
|
||||
+ [Antonin Descampe] added cmake files to the project
|
||||
! [Antonin Descampe] fix.c : replaced "WIN32" by "_MSC_VER" for int64
|
||||
+ [Antonin Descampe] added "OPJ_EXPORT" in openjpeg.h to generate shared lib with win32
|
||||
|
|
|
@ -844,7 +844,6 @@ opj_image_t* pnmtoimage(char *filename, opj_cparameters_t *parameters) {
|
|||
opj_image_cmptparm_t cmptparm[3]; /* maximum of 3 components */
|
||||
opj_image_t * image = NULL;
|
||||
char value;
|
||||
char comment[256];
|
||||
|
||||
f = fopen(filename, "rb");
|
||||
if (!f) {
|
||||
|
@ -856,73 +855,32 @@ opj_image_t* pnmtoimage(char *filename, opj_cparameters_t *parameters) {
|
|||
return 0;
|
||||
value = fgetc(f);
|
||||
|
||||
switch(value) {
|
||||
case '2': /* greyscale image type */
|
||||
case '5':
|
||||
{
|
||||
numcomps = 1;
|
||||
color_space = CLRSPC_GRAY;
|
||||
switch(value) {
|
||||
case '2': /* greyscale image type */
|
||||
case '5':
|
||||
numcomps = 1;
|
||||
color_space = CLRSPC_GRAY;
|
||||
break;
|
||||
|
||||
fgetc(f);
|
||||
case '3': /* RGB image type */
|
||||
case '6':
|
||||
numcomps = 3;
|
||||
color_space = CLRSPC_SRGB;
|
||||
break;
|
||||
|
||||
if (fgetc(f) == '#') {
|
||||
/* skip comments */
|
||||
fseek(f, 0, SEEK_SET);
|
||||
if (value == '2') {
|
||||
fscanf(f, "P2\n");
|
||||
} else if (value == '5') {
|
||||
fscanf(f, "P5\n");
|
||||
}
|
||||
fgets(comment, 256, f);
|
||||
fscanf(f, "%d %d\n255", &w, &h);
|
||||
} else {
|
||||
fseek(f, 0, SEEK_SET);
|
||||
if (value == '2') {
|
||||
fscanf(f, "P2\n%d %d\n255", &w, &h);
|
||||
} else if (value == '5') {
|
||||
fscanf(f, "P5\n%d %d\n255", &w, &h);
|
||||
}
|
||||
}
|
||||
|
||||
fgetc(f); /* <cr><lf> */
|
||||
default:
|
||||
fclose(f);
|
||||
return NULL;
|
||||
}
|
||||
break;
|
||||
|
||||
case '3': /* RGB image type */
|
||||
case '6':
|
||||
{
|
||||
numcomps = 3;
|
||||
color_space = CLRSPC_SRGB;
|
||||
fgetc(f);
|
||||
|
||||
fgetc(f);
|
||||
/* skip comments */
|
||||
while(fgetc(f) == '#') while(fgetc(f) != '\n');
|
||||
|
||||
if (fgetc(f) == '#') {
|
||||
/* skip comments */
|
||||
fseek(f, 0, SEEK_SET);
|
||||
if (value == '3') {
|
||||
fscanf(f, "P3\n");
|
||||
} else if (value == '6') {
|
||||
fscanf(f, "P6\n");
|
||||
}
|
||||
fgets(comment, 256, f);
|
||||
fscanf(f, "%d %d\n255", &w, &h);
|
||||
} else {
|
||||
fseek(f, 0, SEEK_SET);
|
||||
if (value == '3') {
|
||||
fscanf(f, "P3\n%d %d\n255", &w, &h);
|
||||
} else if (value == '6') {
|
||||
fscanf(f, "P6\n%d %d\n255", &w, &h);
|
||||
}
|
||||
}
|
||||
|
||||
fgetc(f); /* <cr><lf> */
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
fclose(f);
|
||||
return NULL;
|
||||
}
|
||||
fseek(f, -1, SEEK_CUR);
|
||||
fscanf(f, "%d %d\n255", &w, &h);
|
||||
fgetc(f); /* <cr><lf> */
|
||||
|
||||
/* initialize image components */
|
||||
memset(&cmptparm[0], 0, 3 * sizeof(opj_image_cmptparm_t));
|
||||
|
|
Loading…
Reference in New Issue