From a07d7a70a0c9f151acfbc80ae8552198b7128255 Mon Sep 17 00:00:00 2001 From: Eric Sommerlade Date: Mon, 23 Feb 2015 06:12:42 -0700 Subject: [PATCH 1/2] added support for uncompressed parameters to tiff image format as described here: expertland.net/question/b6o3n6p9a72341db823b48nl98m91dx8n1/detail.html --- modules/imgcodecs/src/grfmt_tiff.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/modules/imgcodecs/src/grfmt_tiff.cpp b/modules/imgcodecs/src/grfmt_tiff.cpp index 021ff2788c..c4713f25a4 100644 --- a/modules/imgcodecs/src/grfmt_tiff.cpp +++ b/modules/imgcodecs/src/grfmt_tiff.cpp @@ -574,13 +574,19 @@ bool TiffEncoder::writeLibTiff( const Mat& img, const std::vector& params) || !TIFFSetField(pTiffHandle, TIFFTAG_SAMPLESPERPIXEL, channels) || !TIFFSetField(pTiffHandle, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG) || !TIFFSetField(pTiffHandle, TIFFTAG_ROWSPERSTRIP, rowsPerStrip) - || !TIFFSetField(pTiffHandle, TIFFTAG_PREDICTOR, predictor) +// || !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 _buffer(scanlineSize+32); From 998a909705ff8409809c655da28f59e334aee1bd Mon Sep 17 00:00:00 2001 From: Eric Sommerlade Date: Mon, 23 Feb 2015 08:15:34 -0700 Subject: [PATCH 2/2] fixed whitespace issues --- modules/imgcodecs/src/grfmt_tiff.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/modules/imgcodecs/src/grfmt_tiff.cpp b/modules/imgcodecs/src/grfmt_tiff.cpp index c4713f25a4..8f33757be8 100644 --- a/modules/imgcodecs/src/grfmt_tiff.cpp +++ b/modules/imgcodecs/src/grfmt_tiff.cpp @@ -574,17 +574,16 @@ bool TiffEncoder::writeLibTiff( const Mat& img, const std::vector& 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; + if (compression != COMPRESSION_NONE && !TIFFSetField(pTiffHandle, TIFFTAG_PREDICTOR, predictor) ) + { + TIFFClose(pTiffHandle); + return false; } // row buffer, because TIFFWriteScanline modifies the original data!