summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorQt Forward Merge Bot <qt_forward_merge_bot@qt-project.org>2019-10-19 03:05:37 +0200
committerQt Forward Merge Bot <qt_forward_merge_bot@qt-project.org>2019-10-19 03:05:37 +0200
commit04ef5abae8a5b18f5c102f623d7cab5107002071 (patch)
tree1df7e8b6ff2498be3aabd6935e80fae6c9b745ae
parent321ba436db4136f81d121bb570c81df2f25e07e7 (diff)
parent17aa4f6476b95f2a9b08495acce72644f6dbaef6 (diff)
Merge remote-tracking branch 'origin/5.15' into dev
-rw-r--r--src/plugins/imageformats/tiff/qtiffhandler.cpp28
1 files changed, 8 insertions, 20 deletions
diff --git a/src/plugins/imageformats/tiff/qtiffhandler.cpp b/src/plugins/imageformats/tiff/qtiffhandler.cpp
index 57def2c..49edcdf 100644
--- a/src/plugins/imageformats/tiff/qtiffhandler.cpp
+++ b/src/plugins/imageformats/tiff/qtiffhandler.cpp
@@ -624,8 +624,8 @@ bool QTiffHandler::write(const QImage &image)
}
// try to do the conversion in chunks no greater than 16 MB
- int chunks = (width * height / (1024 * 1024 * 16)) + 1;
- int chunkHeight = qMax(height / chunks, 1);
+ const int chunks = int(image.sizeInBytes() / (1024 * 1024 * 16)) + 1;
+ const int chunkHeight = qMax(height / chunks, 1);
int y = 0;
while (y < height) {
@@ -692,22 +692,10 @@ bool QTiffHandler::write(const QImage &image)
}
//// write the data
- // try to do the conversion in chunks no greater than 16 MB
- int chunks = (width * height/ (1024 * 1024 * 16)) + 1;
- int chunkHeight = qMax(height / chunks, 1);
-
- int y = 0;
- while (y < height) {
- QImage chunk = image.copy(0, y, width, qMin(chunkHeight, height - y));
-
- int chunkStart = y;
- int chunkEnd = y + chunk.height();
- while (y < chunkEnd) {
- if (TIFFWriteScanline(tiff, reinterpret_cast<uint32 *>(chunk.scanLine(y - chunkStart)), y) != 1) {
- TIFFClose(tiff);
- return false;
- }
- ++y;
+ for (int y = 0; y < height; ++y) {
+ if (TIFFWriteScanline(tiff, const_cast<uchar *>(image.scanLine(y)), y) != 1) {
+ TIFFClose(tiff);
+ return false;
}
}
TIFFClose(tiff);
@@ -765,7 +753,7 @@ bool QTiffHandler::write(const QImage &image)
return false;
}
// try to do the RGB888 conversion in chunks no greater than 16 MB
- const int chunks = (width * height * 3 / (1024 * 1024 * 16)) + 1;
+ const int chunks = int(image.sizeInBytes() / (1024 * 1024 * 16)) + 1;
const int chunkHeight = qMax(height / chunks, 1);
int y = 0;
@@ -797,7 +785,7 @@ bool QTiffHandler::write(const QImage &image)
return false;
}
// try to do the RGBA8888 conversion in chunks no greater than 16 MB
- const int chunks = (width * height * 4 / (1024 * 1024 * 16)) + 1;
+ const int chunks = int(image.sizeInBytes() / (1024 * 1024 * 16)) + 1;
const int chunkHeight = qMax(height / chunks, 1);
const QImage::Format format = premultiplied ? QImage::Format_RGBA8888_Premultiplied