PDA

View Full Version : QImage() returns Null Image



ustulation
24th July 2012, 12:13
hi,
I am using Visual Studio 2010 with qt 3rd party libraries which belong to 4.7.0.0 (version as mentioned in the .dll files). I'm doing the following:

QImage image(QString(qstrSomeValidFilePathToJpeg));
qDebug() << "NULL?" << image.isNull();
This always returned "true". So i compiled the same line using installed QtSDK and it returned "false", which meant it successfully read the jpeg file. After some analysis i realized that the problem was with the 3rd party qt libraries. QGuid4.dll was of version 4.7.0.0. I replaced this (and others since you must have all .dll's of the same version else it gives errors like "entry point not found...") with the SDK's 4.8.1.0 and the code compiled with visual studio worked fine too (returned "false"). But i'm required to use only 4.7.0 libraries.

<1> why this behaviour? what is lacking in 4.7.0.0 dll's (i need only gui,core and network dll's at the moment)?
<2> how should i proceed if i'm restricted to use only 4.7.0.0?

wysota
24th July 2012, 12:29
It's likely you are missing an image plugin.

http://www.qtcentre.org/faq.php?faq=qt_images#faq_qt_missing_images

A possible solution is to use a png image instead of jpeg.

amleto
24th July 2012, 12:31
did you also include dlls from /imageformats ?

ustulation
24th July 2012, 13:16
@wysota: yes i thought so. so you mean the functionality of plugins has been moved into QtGuid4.dll for 4.8.1? also PNG is not an option. I'm working on building a protocol the client of which that can ask an image in various formats. I have to support atleast jpeg,png and rgb8

@amleto: yes i did that too but it didn't work. maybe qjpegd4.dll i am using is of 4.7.4 while 3rd party libraries are of 4..7.0.0. Could this cause a problem? i cant find plugin dll's of version 4.7.0.0.

wysota
24th July 2012, 13:19
@wysota: yes i thought so. so you mean the functionality of plugins has been moved into QtGuid4.dll for 4.8.1?
No :) I mean for 4.8.1 you have the plugin and for 4.7.0 you don't have it.


also PNG is not an option. I'm working on building a protocol the client of which that can ask an image in various formats. I have to support atleast jpeg,png and rgb8
You need the image plugin then.

ustulation
24th July 2012, 13:26
ah..but why is it that if i replace QtGui4/QtGuid4 .dll's of version 4.7.0 with 4.8.1 in the repository, then it works without any problem. There is no plugin in the cvs online repository.
Secondly when i asked the project owner to allow 4.8.1 dll's he's concerned that it could cause breakage of existing codes that use the 3rd party libraries. Do you know of any functionality of 4.7.0 which has been made obsolete in 4.8.1? (deprecated ones dont cause a problem i think..just that their use is discouraged)

wysota
24th July 2012, 13:45
ah..but why is it that if i replace QtGui4/QtGuid4 .dll's of version 4.7.0 with 4.8.1 in the repository, then it works without any problem. There is no plugin in the cvs online repository.
If you can load jpegs then either you have the plugin or you built the plugin functionality into the library when building the library by passing an appropriate switch to configure.exe.


Secondly when i asked the project owner to allow 4.8.1 dll's he's concerned that it could cause breakage of existing codes that use the 3rd party libraries. Do you know of any functionality of 4.7.0 which has been made obsolete in 4.8.1? (deprecated ones dont cause a problem i think..just that their use is discouraged)
The problem is not about functionality becoming obsolete as code is not removed from Qt libs. However some code might break because of using some flaw or undocumented feature in 4.7.0 that might have been fixed in some later version of the library. The best solution is to ask the maintainer to provide image plugins for 4.7.0 or to provide a version of Qt libs with image loading code embedded into the library itself.

ustulation
24th July 2012, 13:52
thanks! i'll do that.