Merge pull request #5357 from fxtentacle:ha-2.4.11
[platform/upstream/opencv.git] / modules / highgui / src / grfmt_tiff.cpp
index 7871118..c7639fe 100644 (file)
@@ -496,13 +496,18 @@ bool  TiffEncoder::writeLibTiff( const Mat& img, const vector<int>& params)
       || !TIFFSetField(pTiffHandle, TIFFTAG_SAMPLESPERPIXEL, channels)
       || !TIFFSetField(pTiffHandle, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG)
       || !TIFFSetField(pTiffHandle, TIFFTAG_ROWSPERSTRIP, rowsPerStrip)
-      || !TIFFSetField(pTiffHandle, TIFFTAG_PREDICTOR, predictor)
        )
     {
         TIFFClose(pTiffHandle);
         return false;
     }
 
+    if (compression != COMPRESSION_NONE && !TIFFSetField(pTiffHandle, TIFFTAG_PREDICTOR, predictor) )
+    {
+        TIFFClose(pTiffHandle);
+        return false;
+    }
+
     // row buffer, because TIFFWriteScanline modifies the original data!
     size_t scanlineSize = TIFFScanlineSize(pTiffHandle);
     AutoBuffer<uchar> _buffer(scanlineSize+32);