diff options
-rw-r--r-- | src/plugins/imageformats/tiff/qtiffhandler.cpp | 28 |
1 files changed, 8 insertions, 20 deletions
diff --git a/src/plugins/imageformats/tiff/qtiffhandler.cpp b/src/plugins/imageformats/tiff/qtiffhandler.cpp index 0d0a133..d7e46cd 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 |