diff options
author | Sarah Smith <sarah.j.smith@nokia.com> | 2011-11-14 03:51:50 (GMT) |
---|---|---|
committer | Sarah Smith <sarah.j.smith@nokia.com> | 2011-11-14 03:55:38 (GMT) |
commit | 951a997893407b0a26f21fe0acec4701fa3d4279 (patch) | |
tree | ff2967fdd6ba6d6685ebe820fce575c557960860 /src/gui/image | |
parent | 739e705150ad114eb92a1fac34a51d30322ffc31 (diff) | |
download | Qt-951a997893407b0a26f21fe0acec4701fa3d4279.zip Qt-951a997893407b0a26f21fe0acec4701fa3d4279.tar.gz Qt-951a997893407b0a26f21fe0acec4701fa3d4279.tar.bz2 |
Move tga support from Qt3d to Qt.
Rev-By: Samuel Rodal
Fix-for: QTBUG-21955
Part of fix for https://bugreports.qt.nokia.com/browse/QTBUG-21955
Having tga plugin inside a Qt add-on causes packaging problems.
There have been many queries over the years for tga support even tho it
is a niche image format. It is particularly useful for OpenGL work as a
texture format since it is a blittable bitmap, but it is very
innefficient compared to png or jpg.
For this reason only read support is added, and this is documented.
Also add some unit tests.
The unit tests are in the qimagereader suite, and this is the right
place for them as the other formats are tested there.
Noticed that there was an annoying bug with tiff files and chased it
down, in the hope of getting a clean test case PASS. Looks as tho
there is a bit of work for someone to fix the other FAILs, but the ones
for tga are all passing.
Diffstat (limited to 'src/gui/image')
-rw-r--r-- | src/gui/image/qimagereader.cpp | 5 | ||||
-rw-r--r-- | src/gui/image/qtiffhandler.cpp | 6 |
2 files changed, 11 insertions, 0 deletions
diff --git a/src/gui/image/qimagereader.cpp b/src/gui/image/qimagereader.cpp index 411e5e9..2b56e49 100644 --- a/src/gui/image/qimagereader.cpp +++ b/src/gui/image/qimagereader.cpp @@ -1473,11 +1473,16 @@ QByteArray QImageReader::imageFormat(QIODevice *device) \row \o XBM \o X11 Bitmap \row \o XPM \o X11 Pixmap \row \o SVG \o Scalable Vector Graphics + \row \o TGA \o Targa Image Format \endtable Reading and writing SVG files is supported through Qt's \l{QtSvg Module}{SVG Module}. + TGA support only extends to reading non-RLE compressed files. In particular + calls to \l{http://doc.qt.nokia.com/4.7-snapshot/qimageioplugin.html#capabilities}{capabilities} + for the tga plugin returns only QImageIOPlugin::CanRead, not QImageIOPlugin::CanWrite. + To configure Qt with GIF support, pass \c -qt-gif to the \c configure script or check the appropriate option in the graphical installer. diff --git a/src/gui/image/qtiffhandler.cpp b/src/gui/image/qtiffhandler.cpp index 4dc9775..51a500d 100644 --- a/src/gui/image/qtiffhandler.cpp +++ b/src/gui/image/qtiffhandler.cpp @@ -158,7 +158,13 @@ bool QTiffHandler::canRead(QIODevice *device) // current implementation uses TIFFClientOpen which needs to be // able to seek, so sequential devices are not supported + int pos = device->pos(); + if (pos != 0) + device->seek(0); // need the magic from the beginning QByteArray header = device->peek(4); + if (pos != 0) + device->seek(pos); // put it back where we found it + return header == QByteArray::fromRawData("\x49\x49\x2A\x00", 4) || header == QByteArray::fromRawData("\x4D\x4D\x00\x2A", 4); } |