Add support for reading BigTIFF
All recent versions of libtiff has support for the 64bit-indexed BigTIFF format. Allow reading it by recognizing its magic number. [ChangeLog][TIFF] Add support for reading BigTIFF Fixes: QTBUG-80538 Change-Id: I7fcb72d77e4a0bdcb38ab96e9f6cfaff7cf4ad49 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
This commit is contained in:
parent
fe11f37ca0
commit
6124b900d9
|
@ -205,9 +205,14 @@ bool QTiffHandlerPrivate::canRead(QIODevice *device)
|
|||
|
||||
// current implementation uses TIFFClientOpen which needs to be
|
||||
// able to seek, so sequential devices are not supported
|
||||
QByteArray header = device->peek(4);
|
||||
return header == QByteArray::fromRawData("\x49\x49\x2A\x00", 4)
|
||||
|| header == QByteArray::fromRawData("\x4D\x4D\x00\x2A", 4);
|
||||
char h[4];
|
||||
if (device->peek(h, 4) != 4)
|
||||
return false;
|
||||
if ((h[0] == 0x49 && h[1] == 0x49) && (h[2] == 0x2a || h[2] == 0x2b) && h[3] == 0)
|
||||
return true; // Little endian, classic or bigtiff
|
||||
if ((h[0] == 0x4d && h[1] == 0x4d) && h[2] == 0 && (h[3] == 0x2a || h[3] == 0x2b))
|
||||
return true; // Big endian, classic or bigtiff
|
||||
return false;
|
||||
}
|
||||
|
||||
bool QTiffHandlerPrivate::openForRead(QIODevice *device)
|
||||
|
|
|
@ -90,6 +90,9 @@ private slots:
|
|||
void colorSpace_data();
|
||||
void colorSpace();
|
||||
|
||||
void bigtiff_data();
|
||||
void bigtiff();
|
||||
|
||||
private:
|
||||
QString prefix;
|
||||
};
|
||||
|
@ -173,6 +176,10 @@ void tst_qtiff::readImage_data()
|
|||
QTest::newRow("tiled_oddsize_mono") << QString("tiled_oddsize_mono.tiff") << QSize(59, 71);
|
||||
QTest::newRow("16bpc") << QString("16bpc.tiff") << QSize(64, 46);
|
||||
QTest::newRow("gray16") << QString("gray16.tiff") << QSize(64, 46);
|
||||
QTest::newRow("big_rgb") << QString("big_rgb.tiff") << QSize(64, 64);
|
||||
QTest::newRow("big_rgb_bigendian") << QString("big_rgb_bigendian.tiff") << QSize(64, 64);
|
||||
QTest::newRow("big_grayscale") << QString("big_grayscale.tiff") << QSize(64, 64);
|
||||
QTest::newRow("big_16bpc") << QString("big_16bpc.tiff") << QSize(64, 46);
|
||||
}
|
||||
|
||||
void tst_qtiff::readImage()
|
||||
|
@ -665,5 +672,27 @@ void tst_qtiff::colorSpace()
|
|||
QCOMPARE(image2, image);
|
||||
}
|
||||
|
||||
void tst_qtiff::bigtiff_data()
|
||||
{
|
||||
QTest::addColumn<QString>("expectedFile");
|
||||
QTest::addColumn<QString>("bigtiffFile");
|
||||
|
||||
QTest::newRow("big_rgb") << QString("original_rgb.tiff") << QString("big_rgb.tiff");
|
||||
QTest::newRow("big_rgb_bigendian") << QString("original_rgb.tiff") << QString("big_rgb_bigendian.tiff");
|
||||
QTest::newRow("big_grayscale") << QString("original_grayscale.tiff") << QString("big_grayscale.tiff");
|
||||
QTest::newRow("big_16bpc") << QString("16bpc.tiff") << QString("big_16bpc.tiff");
|
||||
}
|
||||
|
||||
void tst_qtiff::bigtiff()
|
||||
{
|
||||
QFETCH(QString, expectedFile);
|
||||
QFETCH(QString, bigtiffFile);
|
||||
|
||||
QImage expectedImage(prefix + expectedFile);
|
||||
QImage bigtiffImage(prefix + bigtiffFile);
|
||||
QVERIFY(!bigtiffImage.isNull());
|
||||
QCOMPARE(expectedImage, bigtiffImage);
|
||||
}
|
||||
|
||||
QTEST_MAIN(tst_qtiff)
|
||||
#include "tst_qtiff.moc"
|
||||
|
|
|
@ -52,5 +52,9 @@
|
|||
<file>tiff/oddsize_mono.tiff</file>
|
||||
<file>tiff/tiled_rgb.tiff</file>
|
||||
<file>tiff/gray16.tiff</file>
|
||||
<file>tiff/big_rgb.tiff</file>
|
||||
<file>tiff/big_16bpc.tiff</file>
|
||||
<file>tiff/big_grayscale.tiff</file>
|
||||
<file>tiff/big_rgb_bigendian.tiff</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue