fixed a problem in convert.c when multiple comments

This commit is contained in:
Antonin Descampe 2006-01-25 15:45:01 +00:00
parent ec2b3b3b3f
commit 2f75846baf
2 changed files with 28 additions and 69 deletions

View File

@ -6,6 +6,7 @@ What's New for OpenJPEG
+ : added + : added
January 25, 2006 January 25, 2006
* [Antonin Descampe] fixed a problem in convert.c when multiple comments
+ [Antonin Descampe] added cmake files to the project + [Antonin Descampe] added cmake files to the project
! [Antonin Descampe] fix.c : replaced "WIN32" by "_MSC_VER" for int64 ! [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 + [Antonin Descampe] added "OPJ_EXPORT" in openjpeg.h to generate shared lib with win32

View File

@ -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_cmptparm_t cmptparm[3]; /* maximum of 3 components */
opj_image_t * image = NULL; opj_image_t * image = NULL;
char value; char value;
char comment[256];
f = fopen(filename, "rb"); f = fopen(filename, "rb");
if (!f) { if (!f) {
@ -859,64 +858,14 @@ opj_image_t* pnmtoimage(char *filename, opj_cparameters_t *parameters) {
switch(value) { switch(value) {
case '2': /* greyscale image type */ case '2': /* greyscale image type */
case '5': case '5':
{
numcomps = 1; numcomps = 1;
color_space = CLRSPC_GRAY; color_space = CLRSPC_GRAY;
fgetc(f);
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> */
}
break; break;
case '3': /* RGB image type */ case '3': /* RGB image type */
case '6': case '6':
{
numcomps = 3; numcomps = 3;
color_space = CLRSPC_SRGB; color_space = CLRSPC_SRGB;
fgetc(f);
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; break;
default: default:
@ -924,6 +873,15 @@ opj_image_t* pnmtoimage(char *filename, opj_cparameters_t *parameters) {
return NULL; return NULL;
} }
fgetc(f);
/* skip comments */
while(fgetc(f) == '#') while(fgetc(f) != '\n');
fseek(f, -1, SEEK_CUR);
fscanf(f, "%d %d\n255", &w, &h);
fgetc(f); /* <cr><lf> */
/* initialize image components */ /* initialize image components */
memset(&cmptparm[0], 0, 3 * sizeof(opj_image_cmptparm_t)); memset(&cmptparm[0], 0, 3 * sizeof(opj_image_cmptparm_t));
for(i = 0; i < numcomps; i++) { for(i = 0; i < numcomps; i++) {