PDA

View Full Version : GIF image now showing up in Windows 8.0



Cupidvogel
28th April 2015, 17:12
I need to show an animated gif image in my application. I tried to do it the normal way, then found it is working everywhere except Windows 8.0. So I did some Googling, found some similar answers here (http://stackoverflow.com/questions/11462704/animated-gif-inst-displayed-with-qt-on-windows) and here (http://www.qtcentre.org/threads/26947-Application-doesn-t-display-images). So what I did is this:

1. Removed the gif image from my resources folder to a folder named imageformats in the same directory as my app binary, and placed the qgif.dll there as well and changed the .pri file accordingly to ensure that these two are properly bundled to be in the same directory after build.

2. Changed my code from



movie = new QMovie(":/icon/dynamic.gif");


to



movie = new QMovie(QDir::currentPath()+"/imageformats/dynamic.gif");


It didn't work (although it works in Windows 7 and 8.1 as normal). So I did some more study and found that for svg images to work the dll has to be placed in the imageformats folder inside plugins folder. So I did a similar thing for my gif image as well.

1. Created a nested folder plugins/imageformats with the image and the gif dll and ensured it remains bundled along with other dependencies in the same folder as the app exe.

2. Changed the code to



movie = new QMovie(QDir::currentPath()+"/plugins/imageformats/dynamic.gif");


3. Changed code in application.cpp to set the library path:



QStringList properPathList;
QStringList libPaths = QCoreApplication::libraryPaths();
QString path = QCoreApplication::applicationDirPath() + "/plugins";
libPaths << path;
properPathList << path << QCoreApplication::applicationDirPath();
properPathList << libPaths;
QCoreApplication::setLibraryPaths(properPathList);


It is still not working. The gif does not show up in Windows 8.0. How do I fix this?

wysota
28th April 2015, 17:40
First of all use QImageReader::supportedImageFormats() to see if the gif plugin is loaded correctly. The plugin should be in imageformats subdirectory of the directory where your application binary resides.

Cupidvogel
28th April 2015, 18:05
Yes, the plugin and the image both are present in the subdirectory imageformats of the same directory where the app binary resides. Will verify the supportedImageFormats methods and get back here..

ChrisW67
28th April 2015, 21:50
QDir::currentPath() could be anywhere on the system and not necessarily where the application executable or plugin library is. Relying on that to find an external file is fragile.

Cupidvogel
29th April 2015, 08:28
Okay, so I verified with the supportedImageFormats method. It shows as not supported (even when the dll is the imageformats folder along with the exe) I changed the gif image location in the code to the one bundled in my resource, but it obviously doesn't show up even then because the format itself is not supported.

ChrisW67
29th April 2015, 09:39
Do you don't say anything about your dev environment. Have you deployed a compatible plugin, that is one from the same Qt library bundle you built with?

Cupidvogel
29th April 2015, 09:42
This still doesn't work in Windows 8.0. Apart from placing the gif dll in the AppDir/imageformats folder, is there anything else that needs to be done?

wysota
29th April 2015, 09:42
What formats do you get as supported? Does Dependency Walker report any missing dependencies for qgif.dll?

Cupidvogel
29th April 2015, 09:44
Do you don't say anything about your dev environment. Have you deployed a compatible plugin, that is one from the same Qt library bundle you built with?

Yes, the one we got from the Qt library itself. Qt 5.3.1 32 bit.


What formats do you get as supported? Does Dependency Walker report any missing dependencies for qgif.dll?

Did not check which formats are supported. Will do. How do I work with dependency walker?

wysota
29th April 2015, 10:06
Did not check which formats are supported.
So how do you know gif is not supported???

Cupidvogel
29th April 2015, 11:59
So how do you know gif is not supported???

Umm no, I just ran a check that if 'gif' is supported then show an alert saying yes, else show an alert saying no. It showed yes on Mac, Windows 8.1 and 7, showed do on 8.0.. :(

wysota
29th April 2015, 12:30
Just stream the output of supportedImageFormats() to qDebug.


qDebug() << QImageReader::supportedImageFormats();

See if other plugins work. And check if dependencies of qgif.dll (if any) are met on your Windows 8.0 system.

Cupidvogel
29th April 2015, 13:09
Just stream the output of supportedImageFormats() to qDebug.


qDebug() << QImageReader::supportedImageFormats();

See if other plugins work. And check if dependencies of qgif.dll (if any) are met on your Windows 8.0 system.

Yes, the problem is that my Windows 8.0 is a separate machine where I don't have Qt or my source code, so I am editing and building on my Windows 8.1, then transferring the entire app folder to my 8.0 and 7 machines and checking. So qDebug() won't make sense there. Instead, I set up an alert stating yes if the gif support is there. It shows yes on Windows 7 and no on Windows 8.0..

What do you mean by dependencies of qgif.dll?

wysota
29th April 2015, 13:11
So qDebug() won't make sense there.
Why not?


Instead, I set up an alert stating yes if the gif support is there. It shows yes on Windows 7 and no on Windows 8.0..
This is obviously not what I meant.


What do you mean by dependencies of qgif.dll?
I meant libraries the plugin may depend on.

Cupidvogel
29th April 2015, 13:54
Where will the qDebug() print to then? :O

Anyway, I am making do with a dialog which shows all the supported formats. Gimme 5 minutes.

And can you tell me which libraries the plugin may depend on?

Added after 39 minutes:

Hi, I got the list of formats supported. In Windows 8.1, bmp, dds, gif, icns, ico, jp2, jpeg, jpg, mng, pbm, pgm, png, ppm, svg, tga, tif, tiff, wbmp, webp, xbm and xpm.

For Windows 8.0, the list is pretty small, without gif, even though the dll is there in the imageformats folder: bmp, pbm, pgm, png, ppm, xbm, xpm.

wysota
29th April 2015, 13:55
Where will the qDebug() print to then? :O
Wherever the debugging output goes, either the console or some system journal.


And can you tell me which libraries the plugin may depend on?
If I could, I wouldn't be asking you to check that. A developer should know how to check dependencies of libraries he uses.


For Windows 8.0, the list is pretty small, without gif, even though the dll is there in the imageformats folder: bmp, pbm, pgm, png, ppm, xbm, xpm.
What about the jpeg plugin? Do you have that dll in your imageformats directory? If not, copy it there and see if jpeg becomes supported.

Cupidvogel
29th April 2015, 14:21
What formats do you get as supported? Does Dependency Walker report any missing dependencies for qgif.dll?

Hi, I got the list of formats supported. In Windows 8.1, bmp, dds, gif, icns, ico, jp2, jpeg, jpg, mng, pbm, pgm, png, ppm, svg, tga, tif, tiff, wbmp, webp, xbm and xpm.

For Windows 8.0, the list is pretty small, without gif, even though the dll is there in the imageformats folder: bmp, pbm, pgm, png, ppm, xbm, xpm.

Added after 5 minutes:


Wherever the debugging output goes, either the console or some system journal.


If I could, I wouldn't be asking you to check that. A developer should know how to check dependencies of libraries he uses.


What about the jpeg plugin? Do you have that dll in your imageformats directory? If not, copy it there and see if jpeg becomes supported.

Correct. A developer should know many things. That's why I am striving to know those things which I don't know yet.

I will add the jpeg library and see if it works..

Added after 20 minutes:

Apology guys. I was using a wrong dll (even though the name is qgif.dll, plus I cannot remember where I acquired it from). So now I again took the dll from my Qt installation plugins folder, and it works fine. No need for any jpeg plugin. Sorry.