probably you arent able to read the images properly from net..are you relying on the finished signal from QNetworkAccessManager?
probably you arent able to read the images properly from net..are you relying on the finished signal from QNetworkAccessManager?
Yes, I am relying on the finished signal from QNetworkAccessManager.
Basically, I have the following code:
Qt Code:
reply->close(); // construct QImage from data QImage img; bool loaded = img.loadFromData(data);To copy to clipboard, switch view to plain text mode
My problem is that "img.loadFromData(data)" returns true in any case, even if the mentioned error messages get printed onto the console. I would be interested in finding a way to catch those error messages such that I would be able to discard the corresponding images.
try using QImageReader , it has functions like canRead() and read() which might be helpful to you
mikeee7 (3rd April 2009)
Hi,
thanks for your help!
I've tried QImageReader as suggested but the functions canRead() and read() cannot detect the corrupt jpeg data either.
Looking at the QImage source code, one can see that QImage internally of course relies on QImageReader and thus only fails when QImageReader fails:
Qt Code:
{ if (fileName.isEmpty()) return false; if (!image.isNull()) { operator=(image); return true; } return false; }To copy to clipboard, switch view to plain text mode
Any other ideas for detecting images that cause the "Corrupt JPEG data" error message?
Thanks,
mikeee7
hmm..thats really odd..anyways, u can maybe try using error() and errorString() of QImageReader, if error is there, u can discard corresponding images
Hi,
I tried QImageReader::error() but it does not seem to cover the "Corrupt JPEG data" error.
I found a thread covering the same problem but there is no real solution:
http://www.qtcentre.org/forum/f-qt-p...es-19703.html/
It would be nice to have some additional error enums included into the QImageReader API that allow users to detect the "Corrupt JPEG data" error...
I wonder if anyone has other ideas to detect those errors except writing the data into a logfile and analyzing the logfile afterwards?
Thanks,
mikeee7
The corruption message comes from libjpeg which is responsible for decoding the image. It succeeds to do it regardless of data corruption thus QImageReader returns true. I don't think there is anything you can do about it, unfortunately. Unless of course libjpeg can report such problems - then it'd be just a matter of slightly modifying the jpeg imageio plugin.
mikeee7 (3rd April 2009)
so wysota, do you think this should be taken up to the trolls? i mean it makes sense that if an image is corrupted, it should be reported..or is it like they know the issue and they r just playing ostrich on it?
You can report it of course it would be worth to check first if libjpeg has any means of notifying about such corruption. If not, Trolls won't be able to do anything about it other than patching libjpeg which is doubtful they would do.
Thanks for your help!
I reported the problem in the Qt tasktracker.
libjpeg provides very detailed status codes, see http://libjpeg.cvs.sourceforge.net/v....h?view=markup. However, qjpeghandler.cpp does not seem to check them. The corresponding function is
Qt Code:
static bool read_jpeg_image(QIODevice *device, QImage *outImage, const QByteArray ¶meters, QSize scaledSize, int inQuality )To copy to clipboard, switch view to plain text mode
Also, it seems that the interface provided by QImageIOHandler would need to be extended to be able to forward additional "status messages" since currently the read() and canRead() methods only return boolean values.
Bookmarks