diff options
author | Qt Forward Merge Bot <qt_forward_merge_bot@qt-project.org> | 2018-10-27 03:01:54 +0200 |
---|---|---|
committer | Qt Forward Merge Bot <qt_forward_merge_bot@qt-project.org> | 2018-10-27 03:01:54 +0200 |
commit | a9be081dacbd307eb277ef1fe6c095677e00248f (patch) | |
tree | 8181fc6d57ef886d4f8bb539061948d8dceb7197 /src | |
parent | 4783c6dc4441ab833050a08996d40d959960ecff (diff) | |
parent | 8455ab6cb29fcccf44977c517689a8ad26781140 (diff) | |
download | qtimageformats-a9be081dacbd307eb277ef1fe6c095677e00248f.tar.gz |
Merge remote-tracking branch 'origin/5.11' into 5.12
Change-Id: I56fb4e7a178ac79c75a846d9a7bcd8f1f3533673
Diffstat (limited to 'src')
-rw-r--r-- | src/plugins/imageformats/tiff/qtiffhandler.cpp | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/src/plugins/imageformats/tiff/qtiffhandler.cpp b/src/plugins/imageformats/tiff/qtiffhandler.cpp index bb6daff..edb5443 100644 --- a/src/plugins/imageformats/tiff/qtiffhandler.cpp +++ b/src/plugins/imageformats/tiff/qtiffhandler.cpp @@ -523,6 +523,15 @@ static QVector<QRgb> effectiveColorTable(const QImage &image) return colors; } +static quint32 defaultStripSize(TIFF *tiff) +{ + // Aim for 4MB strips + qint64 scanSize = qMax(tmsize_t(1), TIFFScanlineSize(tiff)); + qint64 numRows = (4 * 1024 * 1024) / scanSize; + quint32 reqSize = static_cast<quint32>(qBound(qint64(1), numRows, qint64(UINT_MAX))); + return TIFFDefaultStripSize(tiff, reqSize); +} + bool QTiffHandler::write(const QImage &image) { if (!device()->isWritable()) @@ -587,7 +596,7 @@ bool QTiffHandler::write(const QImage &image) if (!TIFFSetField(tiff, TIFFTAG_PHOTOMETRIC, photometric) || !TIFFSetField(tiff, TIFFTAG_COMPRESSION, compression == NoCompression ? COMPRESSION_NONE : COMPRESSION_LZW) || !TIFFSetField(tiff, TIFFTAG_BITSPERSAMPLE, 1) - || !TIFFSetField(tiff, TIFFTAG_ROWSPERSTRIP, TIFFDefaultStripSize(tiff, 0))) { + || !TIFFSetField(tiff, TIFFTAG_ROWSPERSTRIP, defaultStripSize(tiff))) { TIFFClose(tiff); return false; } @@ -623,7 +632,7 @@ bool QTiffHandler::write(const QImage &image) if (!TIFFSetField(tiff, TIFFTAG_PHOTOMETRIC, photometric) || !TIFFSetField(tiff, TIFFTAG_COMPRESSION, compression == NoCompression ? COMPRESSION_NONE : COMPRESSION_LZW) || !TIFFSetField(tiff, TIFFTAG_BITSPERSAMPLE, 8) - || !TIFFSetField(tiff, TIFFTAG_ROWSPERSTRIP, TIFFDefaultStripSize(tiff, 0))) { + || !TIFFSetField(tiff, TIFFTAG_ROWSPERSTRIP, defaultStripSize(tiff))) { TIFFClose(tiff); return false; } @@ -631,7 +640,7 @@ bool QTiffHandler::write(const QImage &image) 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_ROWSPERSTRIP, TIFFDefaultStripSize(tiff, 0))) { + || !TIFFSetField(tiff, TIFFTAG_ROWSPERSTRIP, defaultStripSize(tiff))) { TIFFClose(tiff); return false; } @@ -728,7 +737,7 @@ bool QTiffHandler::write(const QImage &image) || !TIFFSetField(tiff, TIFFTAG_COMPRESSION, compression == NoCompression ? COMPRESSION_NONE : COMPRESSION_LZW) || !TIFFSetField(tiff, TIFFTAG_SAMPLESPERPIXEL, 3) || !TIFFSetField(tiff, TIFFTAG_BITSPERSAMPLE, 8) - || !TIFFSetField(tiff, TIFFTAG_ROWSPERSTRIP, TIFFDefaultStripSize(tiff, 0))) { + || !TIFFSetField(tiff, TIFFTAG_ROWSPERSTRIP, defaultStripSize(tiff))) { TIFFClose(tiff); return false; } @@ -760,7 +769,7 @@ bool QTiffHandler::write(const QImage &image) || !TIFFSetField(tiff, TIFFTAG_SAMPLESPERPIXEL, 4) || !TIFFSetField(tiff, TIFFTAG_BITSPERSAMPLE, 8) || !TIFFSetField(tiff, TIFFTAG_EXTRASAMPLES, 1, &extrasamples) - || !TIFFSetField(tiff, TIFFTAG_ROWSPERSTRIP, TIFFDefaultStripSize(tiff, 0))) { + || !TIFFSetField(tiff, TIFFTAG_ROWSPERSTRIP, defaultStripSize(tiff))) { TIFFClose(tiff); return false; } |