]>
Commit | Line | Data |
---|---|---|
18733c60 SS |
1 | 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 |
2 | --- qt-everywhere-opensource-src-4.8.1/src/plugins/imageformats/tga/qtgafile.cpp.me 2012-03-30 21:54:59.921331145 +0200 | |
3 | +++ qt-everywhere-opensource-src-4.8.1/src/plugins/imageformats/tga/qtgafile.cpp 2012-03-30 21:58:14.516042067 +0200 | |
4 | @@ -41,6 +41,7 @@ | |
5 | ||
6 | #include "qtgafile.h" | |
7 | ||
8 | +#include <QtCore/QBuffer> | |
9 | #include <QtCore/QIODevice> | |
10 | #include <QtCore/QDebug> | |
11 | #include <QtCore/QDateTime> | |
12 | @@ -264,3 +265,16 @@ QImage QTgaFile::readImage() | |
13 | // TODO: add processing of TGA extension information - ie TGA 2.0 files | |
14 | return im; | |
15 | } | |
16 | +/** | |
17 | + * Checks if device contains a valid tga image, *without* changing device | |
18 | + * position. | |
19 | + */ | |
20 | +bool QTgaFile::canRead(QIODevice *device) | |
21 | +{ | |
22 | + QByteArray header = device->peek(HeaderSize); | |
23 | + if (header.size() < HeaderSize) | |
24 | + return false; | |
25 | + QBuffer buffer(&header); | |
26 | + QTgaFile tga(&buffer); | |
27 | + return tga.isValid(); | |
28 | +} | |
29 | 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 | |
30 | --- qt-everywhere-opensource-src-4.8.1/src/plugins/imageformats/tga/qtgafile.h.me 2012-03-30 21:58:39.670023189 +0200 | |
31 | +++ qt-everywhere-opensource-src-4.8.1/src/plugins/imageformats/tga/qtgafile.h 2012-03-30 21:59:06.202317384 +0200 | |
32 | @@ -93,6 +93,8 @@ public: | |
33 | inline QSize size() const; | |
34 | inline Compression compression() const; | |
35 | ||
36 | + static bool canRead(QIODevice *device); | |
37 | + | |
38 | private: | |
39 | static inline quint16 littleEndianInt(const unsigned char *d); | |
40 | ||
41 | 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 | |
42 | --- qt-everywhere-opensource-src-4.8.1/src/plugins/imageformats/tga/qtgahandler.cpp.me 2012-03-30 21:59:17.373303356 +0200 | |
43 | +++ qt-everywhere-opensource-src-4.8.1/src/plugins/imageformats/tga/qtgahandler.cpp 2012-03-30 22:00:13.817226439 +0200 | |
44 | @@ -77,8 +77,7 @@ bool QTgaHandler::canRead(QIODevice *dev | |
45 | qWarning("QTgaHandler::canRead() called with no device"); | |
46 | return false; | |
47 | } | |
48 | - QTgaFile tga(device); | |
49 | - return tga.isValid(); | |
50 | + return QTgaFile::canRead(device); | |
51 | } | |
52 | ||
53 | bool QTgaHandler::read(QImage *image) |