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;
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
&& 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)
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);
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;
/* -------------------------------------------------------------------------- */
" 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
{"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:"
/* ------------------- */
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;
}
}
/* testcase issue427-illegal-tile-offset.jp2 */
- l_tx1 = l_cp->tx0 + l_cp->tdx;
- if (l_tx1 < l_cp->tx0) { /* manage overflow */
- l_tx1 = 0xFFFFFFFFU;
- }
- l_ty1 = l_cp->ty0 + l_cp->tdy;
- if (l_ty1 < l_cp->ty0) { /* manage overflow */
- l_ty1 = 0xFFFFFFFFU;
- }
+ l_tx1 = opj_uint_adds(l_cp->tx0, l_cp->tdx); /* manage overflow */
+ l_ty1 = opj_uint_adds(l_cp->ty0, l_cp->tdy); /* manage overflow */
if ((l_cp->tx0 > l_image->x0) || (l_cp->ty0 > l_image->y0) || (l_tx1 <= l_image->x0) || (l_ty1 <= l_image->y0) ) {
opj_event_msg(p_manager, EVT_ERROR, "Error with SIZ marker: illegal tile offset\n");
return OPJ_FALSE;
set( filenameInput "${kdu_file}.j2c" )
set( filenameRef "${kdu_file}.ppm" )
+ if("${kdu_file}" STREQUAL "a6_mono_colr")
+ set(kdu_test_args -upsample -split-pnm )
+ else()
+ set(kdu_test_args -upsample )
+ endif()
+
add_test(NAME ETS-KDU-${filenameInput}-decode
COMMAND opj_decompress
-i ${INPUT_CONF}/${filenameInput}
-o ${TEMP}/${filenameInput}.ppm
- -upsample
+ ${kdu_test_args}
)
if("${kdu_file}" STREQUAL "a6_mono_colr")