diff options
Diffstat (limited to 'src/plugins/imageformats/tiff')
-rw-r--r-- | src/plugins/imageformats/tiff/main.cpp | 6 | ||||
-rw-r--r-- | src/plugins/imageformats/tiff/qtiffhandler.cpp | 11 |
2 files changed, 11 insertions, 6 deletions
diff --git a/src/plugins/imageformats/tiff/main.cpp b/src/plugins/imageformats/tiff/main.cpp index 2c34097..8882f35 100644 --- a/src/plugins/imageformats/tiff/main.cpp +++ b/src/plugins/imageformats/tiff/main.cpp @@ -60,12 +60,12 @@ QImageIOPlugin::Capabilities QTiffPlugin::capabilities(QIODevice *device, const { if (format == "tiff" || format == "tif") return Capabilities(CanRead | CanWrite); + Capabilities cap; if (!format.isEmpty()) - return 0; + return cap; if (!device->isOpen()) - return 0; + return cap; - Capabilities cap; if (device->isReadable() && QTiffHandler::canRead(device)) cap |= CanRead; if (device->isWritable()) diff --git a/src/plugins/imageformats/tiff/qtiffhandler.cpp b/src/plugins/imageformats/tiff/qtiffhandler.cpp index 1099ac5..f8645ec 100644 --- a/src/plugins/imageformats/tiff/qtiffhandler.cpp +++ b/src/plugins/imageformats/tiff/qtiffhandler.cpp @@ -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) |