summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEirik Aavitsland <eirik.aavitsland@qt.io>2018-06-05 14:07:33 +0200
committerEirik Aavitsland <eirik.aavitsland@qt.io>2018-06-06 07:22:21 +0000
commit254bcd47935d9c9a177c0d2405155b3584b8f1c4 (patch)
treee925ff1b6b88403cf76f5d915a0458a0a990da15
parent470e683fe32af29cc6454c83cc660576d75110fd (diff)
Fix tiffhandler: ensure saved tiffs have suitable ROWSPERSTRIP tag set
When writing an image without compression, libtiff will automatically store it in strips of default size, and add a ROWSPERSTRIP tag accordingly. However, if compression is enabled, libtiff does not do this. The lack of this tag may create trouble for readers. Fix by explicitly setting the tag in all cases. [ChangeLog][TIFF] Ensure saved tiffs have suitable ROWSPERSTRIP tag set Task-number: QTBUG-68609 Change-Id: I838c83be25158d7f13e220098e960010b8cb2789 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
-rw-r--r--src/plugins/imageformats/tiff/qtiffhandler.cpp15
1 files changed, 10 insertions, 5 deletions
diff --git a/src/plugins/imageformats/tiff/qtiffhandler.cpp b/src/plugins/imageformats/tiff/qtiffhandler.cpp
index 8f3d3e4..84221d6 100644
--- a/src/plugins/imageformats/tiff/qtiffhandler.cpp
+++ b/src/plugins/imageformats/tiff/qtiffhandler.cpp
@@ -558,7 +558,8 @@ bool QTiffHandler::write(const QImage &image)
photometric = PHOTOMETRIC_MINISWHITE;
if (!TIFFSetField(tiff, TIFFTAG_PHOTOMETRIC, photometric)
|| !TIFFSetField(tiff, TIFFTAG_COMPRESSION, compression == NoCompression ? COMPRESSION_NONE : COMPRESSION_LZW)
- || !TIFFSetField(tiff, TIFFTAG_BITSPERSAMPLE, 1)) {
+ || !TIFFSetField(tiff, TIFFTAG_BITSPERSAMPLE, 1)
+ || !TIFFSetField(tiff, TIFFTAG_ROWSPERSTRIP, TIFFDefaultStripSize(tiff, 0))) {
TIFFClose(tiff);
return false;
}
@@ -593,14 +594,16 @@ bool QTiffHandler::write(const QImage &image)
photometric = PHOTOMETRIC_MINISWHITE;
if (!TIFFSetField(tiff, TIFFTAG_PHOTOMETRIC, photometric)
|| !TIFFSetField(tiff, TIFFTAG_COMPRESSION, compression == NoCompression ? COMPRESSION_NONE : COMPRESSION_LZW)
- || !TIFFSetField(tiff, TIFFTAG_BITSPERSAMPLE, 8)) {
+ || !TIFFSetField(tiff, TIFFTAG_BITSPERSAMPLE, 8)
+ || !TIFFSetField(tiff, TIFFTAG_ROWSPERSTRIP, TIFFDefaultStripSize(tiff, 0))) {
TIFFClose(tiff);
return false;
}
} else {
if (!TIFFSetField(tiff, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_PALETTE)
|| !TIFFSetField(tiff, TIFFTAG_COMPRESSION, compression == NoCompression ? COMPRESSION_NONE : COMPRESSION_LZW)
- || !TIFFSetField(tiff, TIFFTAG_BITSPERSAMPLE, 8)) {
+ || !TIFFSetField(tiff, TIFFTAG_BITSPERSAMPLE, 8)
+ || !TIFFSetField(tiff, TIFFTAG_ROWSPERSTRIP, TIFFDefaultStripSize(tiff, 0))) {
TIFFClose(tiff);
return false;
}
@@ -652,7 +655,8 @@ bool QTiffHandler::write(const QImage &image)
if (!TIFFSetField(tiff, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_RGB)
|| !TIFFSetField(tiff, TIFFTAG_COMPRESSION, compression == NoCompression ? COMPRESSION_NONE : COMPRESSION_LZW)
|| !TIFFSetField(tiff, TIFFTAG_SAMPLESPERPIXEL, 3)
- || !TIFFSetField(tiff, TIFFTAG_BITSPERSAMPLE, 8)) {
+ || !TIFFSetField(tiff, TIFFTAG_BITSPERSAMPLE, 8)
+ || !TIFFSetField(tiff, TIFFTAG_ROWSPERSTRIP, TIFFDefaultStripSize(tiff, 0))) {
TIFFClose(tiff);
return false;
}
@@ -683,7 +687,8 @@ bool QTiffHandler::write(const QImage &image)
|| !TIFFSetField(tiff, TIFFTAG_COMPRESSION, compression == NoCompression ? COMPRESSION_NONE : COMPRESSION_LZW)
|| !TIFFSetField(tiff, TIFFTAG_SAMPLESPERPIXEL, 4)
|| !TIFFSetField(tiff, TIFFTAG_BITSPERSAMPLE, 8)
- || !TIFFSetField(tiff, TIFFTAG_EXTRASAMPLES, 1, &extrasamples)) {
+ || !TIFFSetField(tiff, TIFFTAG_EXTRASAMPLES, 1, &extrasamples)
+ || !TIFFSetField(tiff, TIFFTAG_ROWSPERSTRIP, TIFFDefaultStripSize(tiff, 0))) {
TIFFClose(tiff);
return false;
}