From: mayeut Date: Fri, 21 Aug 2015 17:54:22 +0000 (+0200) Subject: TIFF can output CMYK X-Git-Tag: v2.1.1~22^2~83 X-Git-Url: https://main.carlh.net/gitweb/?a=commitdiff_plain;h=f98df1c715df24176fa616046cfabbffde680c6f;p=openjpeg.git TIFF can output CMYK --- diff --git a/src/bin/jp2/converttif.c b/src/bin/jp2/converttif.c index daddbfee..f164989f 100644 --- a/src/bin/jp2/converttif.c +++ b/src/bin/jp2/converttif.c @@ -183,7 +183,18 @@ int imagetotif(opj_image_t * image, const char *outfile) numcomps = image->numcomps; - if (numcomps > 2U) { + if (image->color_space == OPJ_CLRSPC_CMYK) { + if (numcomps < 4U) { + fprintf(stderr,"imagetotif: CMYK images shall be composed of at least 4 planes.\n"); + fprintf(stderr,"\tAborting\n"); + return 1; + } + tiPhoto = PHOTOMETRIC_SEPARATED; + if (numcomps > 4U) { + numcomps = 4U; /* Alpha not supported */ + } + } + else if (numcomps > 2U) { tiPhoto = PHOTOMETRIC_RGB; if (numcomps > 4U) { numcomps = 4U; @@ -266,6 +277,7 @@ int imagetotif(opj_image_t * image, const char *outfile) TIFFSetField(tif, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG); TIFFSetField(tif, TIFFTAG_PHOTOMETRIC, tiPhoto); TIFFSetField(tif, TIFFTAG_ROWSPERSTRIP, 1); + strip_size = TIFFStripSize(tif); rowStride = ((OPJ_SIZE_T)width * numcomps * (OPJ_SIZE_T)bps + 7U) / 8U; if (rowStride != (OPJ_SIZE_T)strip_size) { diff --git a/src/bin/jp2/opj_decompress.c b/src/bin/jp2/opj_decompress.c index 76f592fd..ac17b69d 100644 --- a/src/bin/jp2/opj_decompress.c +++ b/src/bin/jp2/opj_decompress.c @@ -1359,12 +1359,10 @@ int main(int argc, char **argv) if(image->color_space == OPJ_CLRSPC_SYCC){ color_sycc_to_rgb(image); } - else - if(image->color_space == OPJ_CLRSPC_CMYK){ + else if((image->color_space == OPJ_CLRSPC_CMYK) && (parameters.cod_format != TIF_DFMT)){ color_cmyk_to_rgb(image); } - else - if(image->color_space == OPJ_CLRSPC_EYCC){ + else if(image->color_space == OPJ_CLRSPC_EYCC){ color_esycc_to_rgb(image); }