|
|
e09033 |
diff -up qt-everywhere-opensource-src-4.8.1/src/plugins/imageformats/tga/qtgafile.cpp.me qt-everywhere-opensource-src-4.8.1/src/plugins/imageformats/tga/qtgafile.cpp
|
|
|
e09033 |
--- qt-everywhere-opensource-src-4.8.1/src/plugins/imageformats/tga/qtgafile.cpp.me 2012-03-30 21:54:59.921331145 +0200
|
|
|
e09033 |
+++ qt-everywhere-opensource-src-4.8.1/src/plugins/imageformats/tga/qtgafile.cpp 2012-03-30 21:58:14.516042067 +0200
|
|
|
e09033 |
@@ -41,6 +41,7 @@
|
|
|
e09033 |
|
|
|
e09033 |
#include "qtgafile.h"
|
|
|
e09033 |
|
|
|
e09033 |
+#include <QtCore/QBuffer>
|
|
|
e09033 |
#include <QtCore/QIODevice>
|
|
|
e09033 |
#include <QtCore/QDebug>
|
|
|
e09033 |
#include <QtCore/QDateTime>
|
|
|
e09033 |
@@ -264,3 +265,16 @@ QImage QTgaFile::readImage()
|
|
|
e09033 |
// TODO: add processing of TGA extension information - ie TGA 2.0 files
|
|
|
e09033 |
return im;
|
|
|
e09033 |
}
|
|
|
e09033 |
+/**
|
|
|
e09033 |
+ * Checks if device contains a valid tga image, *without* changing device
|
|
|
e09033 |
+ * position.
|
|
|
e09033 |
+ */
|
|
|
e09033 |
+bool QTgaFile::canRead(QIODevice *device)
|
|
|
e09033 |
+{
|
|
|
e09033 |
+ QByteArray header = device->peek(HeaderSize);
|
|
|
e09033 |
+ if (header.size() < HeaderSize)
|
|
|
e09033 |
+ return false;
|
|
|
e09033 |
+ QBuffer buffer(&header);
|
|
|
e09033 |
+ QTgaFile tga(&buffer);
|
|
|
e09033 |
+ return tga.isValid();
|
|
|
e09033 |
+}
|
|
|
e09033 |
diff -up qt-everywhere-opensource-src-4.8.1/src/plugins/imageformats/tga/qtgafile.h.me qt-everywhere-opensource-src-4.8.1/src/plugins/imageformats/tga/qtgafile.h
|
|
|
e09033 |
--- qt-everywhere-opensource-src-4.8.1/src/plugins/imageformats/tga/qtgafile.h.me 2012-03-30 21:58:39.670023189 +0200
|
|
|
e09033 |
+++ qt-everywhere-opensource-src-4.8.1/src/plugins/imageformats/tga/qtgafile.h 2012-03-30 21:59:06.202317384 +0200
|
|
|
e09033 |
@@ -93,6 +93,8 @@ public:
|
|
|
e09033 |
inline QSize size() const;
|
|
|
e09033 |
inline Compression compression() const;
|
|
|
e09033 |
|
|
|
e09033 |
+ static bool canRead(QIODevice *device);
|
|
|
e09033 |
+
|
|
|
e09033 |
private:
|
|
|
e09033 |
static inline quint16 littleEndianInt(const unsigned char *d);
|
|
|
e09033 |
|
|
|
e09033 |
diff -up qt-everywhere-opensource-src-4.8.1/src/plugins/imageformats/tga/qtgahandler.cpp.me qt-everywhere-opensource-src-4.8.1/src/plugins/imageformats/tga/qtgahandler.cpp
|
|
|
e09033 |
--- qt-everywhere-opensource-src-4.8.1/src/plugins/imageformats/tga/qtgahandler.cpp.me 2012-03-30 21:59:17.373303356 +0200
|
|
|
e09033 |
+++ qt-everywhere-opensource-src-4.8.1/src/plugins/imageformats/tga/qtgahandler.cpp 2012-03-30 22:00:13.817226439 +0200
|
|
|
e09033 |
@@ -77,8 +77,7 @@ bool QTgaHandler::canRead(QIODevice *dev
|
|
|
e09033 |
qWarning("QTgaHandler::canRead() called with no device");
|
|
|
e09033 |
return false;
|
|
|
e09033 |
}
|
|
|
e09033 |
- QTgaFile tga(device);
|
|
|
e09033 |
- return tga.isValid();
|
|
|
e09033 |
+ return QTgaFile::canRead(device);
|
|
|
e09033 |
}
|
|
|
e09033 |
|
|
|
e09033 |
bool QTgaHandler::read(QImage *image)
|