diff --git a/src/bin/jp2/convert.c b/src/bin/jp2/convert.c index a540128f..730ab909 100644 --- a/src/bin/jp2/convert.c +++ b/src/bin/jp2/convert.c @@ -1890,6 +1890,21 @@ opj_image_t* pnmtoimage(const char *filename, opj_cparameters_t *parameters) return image; }/* pnmtoimage() */ +static int are_comps_similar(opj_image_t * image) +{ + unsigned int i; + for (i = 1; i < image->numcomps; i++) { + if (image->comps[0].dx != image->comps[i].dx || + image->comps[0].dy != image->comps[i].dy || + image->comps[0].prec != image->comps[i].prec || + image->comps[0].sgnd != image->comps[i].sgnd) { + return OPJ_FALSE; + } + } + return OPJ_TRUE; +} + + int imagetopnm(opj_image_t * image, const char *outfile, int force_split) { int *red, *green, *blue, *alpha; @@ -1926,15 +1941,7 @@ int imagetopnm(opj_image_t * image, const char *outfile, int force_split) } if ((force_split == 0) && - (ncomp == 2 /* GRAYA */ - || (ncomp > 2 /* RGB, RGBA */ - && image->comps[0].dx == image->comps[1].dx - && image->comps[1].dx == image->comps[2].dx - && image->comps[0].dy == image->comps[1].dy - && image->comps[1].dy == image->comps[2].dy - && image->comps[0].prec == image->comps[1].prec - && image->comps[1].prec == image->comps[2].prec - ))) { + are_comps_similar(image)) { fdest = fopen(outfile, "wb"); if (!fdest) {