Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
KDE:Qt
libqt4-sql-plugins
handle-tga-files-properly.diff
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File handle-tga-files-properly.diff of Package libqt4-sql-plugins
Index: src/plugins/imageformats/tga/qtgafile.cpp =================================================================== --- src/plugins/imageformats/tga/qtgafile.cpp.orig +++ src/plugins/imageformats/tga/qtgafile.cpp @@ -41,6 +41,7 @@ #include "qtgafile.h" +#include <QtCore/QBuffer> #include <QtCore/QIODevice> #include <QtCore/QDebug> #include <QtCore/QDateTime> @@ -266,3 +267,16 @@ QImage QTgaFile::readImage() // TODO: add processing of TGA extension information - ie TGA 2.0 files return im; } +/** + * Checks if device contains a valid tga image, *without* changing device + * position. + */ +bool QTgaFile::canRead(QIODevice *device) +{ + QByteArray header = device->peek(HeaderSize); + if (header.size() < HeaderSize) + return false; + QBuffer buffer(&header); + QTgaFile tga(&buffer); + return tga.isValid(); +} Index: src/plugins/imageformats/tga/qtgafile.h =================================================================== --- src/plugins/imageformats/tga/qtgafile.h.orig +++ src/plugins/imageformats/tga/qtgafile.h @@ -93,6 +93,8 @@ public: inline QSize size() const; inline Compression compression() const; + static bool canRead(QIODevice *device); + private: static inline quint16 littleEndianInt(const unsigned char *d); Index: src/plugins/imageformats/tga/qtgahandler.cpp =================================================================== --- src/plugins/imageformats/tga/qtgahandler.cpp.orig +++ src/plugins/imageformats/tga/qtgahandler.cpp @@ -77,8 +77,7 @@ bool QTgaHandler::canRead(QIODevice *dev qWarning("QTgaHandler::canRead() called with no device"); return false; } - QTgaFile tga(device); - return tga.isValid(); + return QTgaFile::canRead(device); } bool QTgaHandler::read(QImage *image)
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor