summaryrefslogtreecommitdiff
path: root/src/bin
diff options
context:
space:
mode:
authormayeut <mayeut@users.noreply.github.com>2015-07-11 11:35:21 +0200
committermayeut <mayeut@users.noreply.github.com>2015-07-11 11:35:21 +0200
commitdc43ebf96c079fb2a91a0e18f4d8f180855dd9ac (patch)
tree40fb0609300f36f8f4a694a5cf14b5dba8962783 /src/bin
parenta7060dae1c689f994643a232c185307fe9545a84 (diff)
Add option to force component splitting in imagetopnm
Update uclouvain/openjpeg#289
Diffstat (limited to 'src/bin')
-rw-r--r--src/bin/jp2/convert.c9
-rw-r--r--src/bin/jp2/convert.h2
-rw-r--r--src/bin/jp2/opj_decompress.c9
3 files changed, 13 insertions, 7 deletions
diff --git a/src/bin/jp2/convert.c b/src/bin/jp2/convert.c
index 92e043b6..5cde4fbd 100644
--- a/src/bin/jp2/convert.c
+++ b/src/bin/jp2/convert.c
@@ -1350,7 +1350,7 @@ opj_image_t* pnmtoimage(const char *filename, opj_cparameters_t *parameters) {
return image;
}/* pnmtoimage() */
-int imagetopnm(opj_image_t * image, const char *outfile)
+int imagetopnm(opj_image_t * image, const char *outfile, int force_split)
{
int *red, *green, *blue, *alpha;
int wr, hr, max;
@@ -1380,7 +1380,8 @@ int imagetopnm(opj_image_t * image, const char *outfile)
if(want_gray) ncomp = 1;
- if (ncomp == 2 /* GRAYA */
+ 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
@@ -1388,8 +1389,8 @@ int imagetopnm(opj_image_t * image, const char *outfile)
&& image->comps[1].dy == image->comps[2].dy
&& image->comps[0].prec == image->comps[1].prec
&& image->comps[1].prec == image->comps[2].prec
- ))
- {
+ )))
+ {
fdest = fopen(outfile, "wb");
if (!fdest)
diff --git a/src/bin/jp2/convert.h b/src/bin/jp2/convert.h
index d375e86b..51018c0b 100644
--- a/src/bin/jp2/convert.h
+++ b/src/bin/jp2/convert.h
@@ -91,7 +91,7 @@ opj_image_t* pgxtoimage(const char *filename, opj_cparameters_t *parameters);
int imagetopgx(opj_image_t *image, const char *outfile);
opj_image_t* pnmtoimage(const char *filename, opj_cparameters_t *parameters);
-int imagetopnm(opj_image_t *image, const char *outfile);
+int imagetopnm(opj_image_t *image, const char *outfile, int force_split);
/* RAW conversion */
int imagetoraw(opj_image_t * image, const char *outfile);
diff --git a/src/bin/jp2/opj_decompress.c b/src/bin/jp2/opj_decompress.c
index c6e5cff8..7479097b 100644
--- a/src/bin/jp2/opj_decompress.c
+++ b/src/bin/jp2/opj_decompress.c
@@ -145,6 +145,8 @@ typedef struct opj_decompress_params
int force_rgb;
/* upsample components according to their dx/dy values */
int upsample;
+ /* split output components to different files */
+ int split_pnm;
}opj_decompress_parameters;
/* -------------------------------------------------------------------------- */
@@ -218,6 +220,8 @@ static void decode_help_display(void) {
" Force output image colorspace to RGB\n"
" -upsample\n"
" Downsampled components will be upsampled to image size\n"
+ " -split-pnm\n"
+ " Split output components to different files when writing to PNM\n"
"\n");
/* UniPG>> */
#ifdef USE_JPWL
@@ -506,7 +510,8 @@ int parse_cmdline_decoder(int argc, char **argv, opj_decompress_parameters *para
{"ImgDir", REQ_ARG, NULL ,'y'},
{"OutFor", REQ_ARG, NULL ,'O'},
{"force-rgb", NO_ARG, &(parameters->force_rgb), 1},
- {"upsample", NO_ARG, &(parameters->upsample), 1}
+ {"upsample", NO_ARG, &(parameters->upsample), 1},
+ {"split-pnm", NO_ARG, &(parameters->split_pnm), 1}
};
const char optlist[] = "i:o:r:l:x:d:t:p:"
@@ -1433,7 +1438,7 @@ int main(int argc, char **argv)
/* ------------------- */
switch (parameters.cod_format) {
case PXM_DFMT: /* PNM PGM PPM */
- if (imagetopnm(image, parameters.outfile)) {
+ if (imagetopnm(image, parameters.outfile, parameters.split_pnm)) {
fprintf(stderr,"[ERROR] Outfile %s not generated\n",parameters.outfile);
failed = 1;
}