Bug 189338 - TGA header parsing looks fairly broken
Summary: TGA header parsing looks fairly broken
Status: RESOLVED DUPLICATE of bug 188191
Alias: None
Product: kdelibs
Classification: Unmaintained
Component: kimgio (show other bugs)
Version: unspecified
Platform: Compiled Sources Unspecified
: NOR normal
Target Milestone: ---
Assignee: kdelibs bugs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-04-11 03:45 UTC by peaches
Modified: 2009-10-16 16:29 UTC (History)
3 users (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments
fix (838 bytes, patch)
2009-04-11 03:47 UTC, peaches
Details

Note You need to log in before you can comment on or make changes to this bug.
Description peaches 2009-04-11 03:45:10 UTC
Version:           KDE4 trunk r951942, qt-copy trunk r942603 (using Devel)
Installed from:    Compiled sources

I tried to find why Gwenview fails to display my TGA files (some metainfo error) for me, while other KDE apps (and thumbnail creator) don't. So it turns out that depending on how Qt's QImage plugins are accessed, QImageReader will either determine probable format by the file extension and try that first, or ask the plugin to parse the data.

tga.cpp/TGAPlugin::capabilities(..) claims to handle the filetype-predetermined TGA's fine without even looking at the data, and does handle them pretty well, but Gwenview accesses QImageReader with just the image data which then requires TGAHandler::canRead to parse the data for possible format match.

According to Qt4 docs:
TGAHandler::canRead looks to have some problems for parsing TGA header data:
 it uses QIODevice::readLine which unintentionally stops reading after any coincidental newline characters (saw this in one of my TGA's)
 it creates variable QString(QByteArray) which unintentionally stops copying data after any coincidental null characters (very common)
 i can't figure out what exactly the QRegExp header parser is doing, after i looked up a TGA specification doc online..

The QRegExp in the patch I have here is not any in depth look into TGA header format, particularly the last character which I only assume is what is meant by 'pixel format' in the tga.cpp file top commentary as to what tga.cpp is supposed to support. I just know TGAHandler::canRead looks fairly broken as it is now, and I think this is a fairly reasonable fix for times when TGAHandler::canRead is actually used by KDE apps (but with QRegExp caveat above!).
Comment 1 peaches 2009-04-11 03:47:08 UTC
Created attachment 32755 [details]
fix
Comment 2 Teemu Rytilahti 2009-05-24 02:20:34 UTC
See #192191, it may be related. Anyways, the regexp is not used anymore in trunk since r960288.
Comment 3 Frédéric COIFFIER 2009-05-26 11:32:18 UTC
I don't know if this problem is the same as mine but I can't open TGA files with gwenview-4.2.3 : it succeeds to display thumbnails but when I open a picture, I get an error 'Loading meta information failed'
Comment 4 Christoph Feck 2009-10-16 04:58:17 UTC
Is this still a problem on KDE 4.3? There were some fixes related to header parsing.

Thanks.
Comment 5 Frédéric COIFFIER 2009-10-16 12:03:05 UTC
With Gwenview 2.3.2 (KDE 4.3.2), I can't find a TGA picture on my HD which isn't readable by Gwenview.
So, the problem may be solved.
Comment 6 Christoph Feck 2009-10-16 16:29:42 UTC

*** This bug has been marked as a duplicate of bug 188191 ***