Merge pull request #528 from mayeut/zlib-1.2.8
[openjpeg.git] / src / bin / jp2 / converttif.c
index 21bb11f8068862b55a6d832295ae789d0585d212..e8ff38f354d61daec80c31e3866d00047689013a 100644 (file)
@@ -825,18 +825,14 @@ opj_image_t* tiftoimage(const char *filename, opj_cparameters_t *parameters)
        w= (int)tiWidth;
        h= (int)tiHeight;
        
-       if((tiBps > 16U) || ((tiBps != 1U) && (tiBps & 1U))) tiBps = 0U;
-       if(tiPhoto != PHOTOMETRIC_MINISBLACK && tiPhoto != PHOTOMETRIC_RGB) tiPhoto = 0;
-       
-       if( !tiBps || !tiPhoto)
-       {
-               if( !tiBps)
-                       fprintf(stderr,"tiftoimage: Bits=%d, Only 1, 2, 4, 6, 8, 10, 12, 14 and 16 bits implemented\n",tiBps);
-               else
-                       if( !tiPhoto)
-                               fprintf(stderr,"tiftoimage: Bad color format %d.\n\tOnly RGB(A)"
-                                                               " and GRAY(A) has been implemented\n",(int) tiPhoto);
-               
+       if((tiBps > 16U) || ((tiBps != 1U) && (tiBps & 1U))) {
+               fprintf(stderr,"tiftoimage: Bits=%d, Only 1, 2, 4, 6, 8, 10, 12, 14 and 16 bits implemented\n",tiBps);
+               fprintf(stderr,"\tAborting\n");
+               TIFFClose(tif);
+               return NULL;
+       }
+       if(tiPhoto != PHOTOMETRIC_MINISBLACK && tiPhoto != PHOTOMETRIC_RGB) {
+               fprintf(stderr,"tiftoimage: Bad color format %d.\n\tOnly RGB(A) and GRAY(A) has been implemented\n",(int) tiPhoto);
                fprintf(stderr,"\tAborting\n");
                TIFFClose(tif);
                return NULL;
@@ -977,6 +973,7 @@ opj_image_t* tiftoimage(const char *filename, opj_cparameters_t *parameters)
        {
                planes[j] = image->comps[j].data;
        }
+       image->comps[numcomps - 1].alpha = (OPJ_UINT16)(1 - (numcomps & 1));
                
        strip_size = TIFFStripSize(tif);