summaryrefslogtreecommitdiffstats
path: root/src/plugins/imageformats/tiff/qtiffhandler.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/imageformats/tiff/qtiffhandler.cpp')
-rw-r--r--src/plugins/imageformats/tiff/qtiffhandler.cpp31
1 files changed, 29 insertions, 2 deletions
diff --git a/src/plugins/imageformats/tiff/qtiffhandler.cpp b/src/plugins/imageformats/tiff/qtiffhandler.cpp
index b5d80f9..e34ea25 100644
--- a/src/plugins/imageformats/tiff/qtiffhandler.cpp
+++ b/src/plugins/imageformats/tiff/qtiffhandler.cpp
@@ -385,11 +385,38 @@ bool QTiffHandler::read(QImage *image)
}
image->setColorTable(qtColorTable);
- for (uint32 y=0; y<height; ++y) {
- if (TIFFReadScanline(tiff, image->scanLine(y), y, 0) < 0) {
+
+ if (TIFFIsTiled(tiff)) {
+ quint32 tileWidth, tileLength;
+ TIFFGetField(tiff, TIFFTAG_TILEWIDTH, &tileWidth);
+ TIFFGetField(tiff, TIFFTAG_TILELENGTH, &tileLength);
+ uchar *buf = (uchar *)_TIFFmalloc(TIFFTileSize(tiff));
+ if (!tileWidth || !tileLength || !buf) {
+ _TIFFfree(buf);
d->close();
return false;
}
+ for (quint32 y = 0; y < height; y += tileLength) {
+ for (quint32 x = 0; x < width; x += tileWidth) {
+ if (TIFFReadTile(tiff, buf, x, y, 0, 0) < 0) {
+ _TIFFfree(buf);
+ d->close();
+ return false;
+ }
+ quint32 linesToCopy = qMin(tileLength, height - y);
+ quint32 widthToCopy = qMin(tileWidth, width - x);
+ for (quint32 i = 0; i < linesToCopy; i++)
+ ::memcpy(image->scanLine(y + i) + x, buf + (i * tileWidth), widthToCopy);
+ }
+ }
+ _TIFFfree(buf);
+ } else {
+ for (uint32 y=0; y<height; ++y) {
+ if (TIFFReadScanline(tiff, image->scanLine(y), y, 0) < 0) {
+ d->close();
+ return false;
+ }
+ }
}
// free redTable, greenTable and greenTable done by libtiff