PDA

View Full Version : QPixmap won't work on some JPGs



durbrak
28th October 2006, 18:58
Hello,
I'm having some kind of weird problem. I have a small collection of jpg-images and I'm able to display almost all of them using QPixmap. However on some image files this just doesn't work. I just did a

myLabel->setPixmap(QPixmap("myimagefolger/12.jpg"));

So, I don't know what the problem is but I searched online for some pictures which QPixmap can't display. I found this:

http://ia.imdb.com/media/imdb/01/I/26/16/12m.jpg

To reproduce this behavior simply save this image on your hard disk and let your Qt program display it via QPixmap/QLabel (by the way, QPixmap::isValid() returns false on this image).

I'm using Qt 4.2.1 and 4.1.4 had the same problem.

Thank you guys in advance!

Edit:
Well, that's awkward - I just tried to open this image with Adobe Photoshop but Photoshop declined the image saying "Could not complete your request because an unknown or invalid JPEG marker type is found."
Is there some workaround/hack for this?

Edit 2:
Umm lol.. I just renamed the file from "12m.jpg" to "12m.gif" and now Photoshop can open it :D. So this basically means, that my Qt doesn't support GIF?

jacek
28th October 2006, 19:06
To reproduce this behavior simply save this image on your hard disk and let your Qt program display it via QPixmap/QLabel (by the way, QPixmap::isValid() returns false on this image).
I can't view that image with Qt 4 too, by it's probably because I don't have GIF (sic!) support enabled.


$ wget http://ia.imdb.com/media/imdb/01/I/26/16/12m.jpg
...
$ file 12m.jpg
12m.jpg: GIF image data, version 87a, 94 x 140

jacek
28th October 2006, 19:08
So this basically means, that my Qt doesn't support GIF?
Qt supports GIF, but it's disabled by default.

durbrak
28th October 2006, 19:32
Thank you jacek.
One more thing - to enable it the documentation says "To configure Qt with GIF support, pass -qt-gif to the configure script". Is there some other "simpler" way of enabling it? I don't want to rebuild the whole library each time I change some option...

wysota
28th October 2006, 19:41
You have to rebuild the library. You can omit building tools and examples and all the other stuff (is there any other stuff?) by issuing make sub-src instead of make (substitute "make" with your build command). In theory you could only rebuild this library which holds references to image formats (QtGui and maybe also QtCore).

jacek
28th October 2006, 20:02
Is there some other "simpler" way of enabling it? I don't want to rebuild the whole library each time I change some option...
You could try to compile only the plugin.

durbrak
28th October 2006, 21:02
I tried "configure -qt-gif" and after it was done it told me to run "nmake". So I did and after ~15min this error always comes up (even though the qjpeg1.dll is there):

link /LIBPATH:"c:\Qt\4.2.1\lib" /LIBPATH:"c:\Qt\4.2.1\lib" /NOLOGO /INCR
EMENTAL:NO /INCREMENTAL:NO /DLL /VERSION:1.00 /OUT:..\..\..\..\plugins\imageform
ats\qjpeg1.dll @C:\DOCUME~1\User\LOCALS~1\Temp\nm372.tmp
LINK : fatal error LNK1104: cannot open file '..\..\..\..\plugins\imageformats\q
jpeg1.dll'
NMAKE : fatal error U1077: '"C:\Program Files\Microsoft Visual Studio 2005\VC\BI
N\link.EXE"' : return code '0x450'
Stop.
NMAKE : fatal error U1077: '"C:\Program Files\Microsoft Visual Studio 2005\VC\BI
N\nmake.exe"' : return code '0x2'
Stop.
NMAKE : fatal error U1077: 'cd' : return code '0x2'
Stop.
NMAKE : fatal error U1077: 'cd' : return code '0x2'
Stop.
NMAKE : fatal error U1077: 'cd' : return code '0x2'
Stop.
NMAKE : fatal error U1077: 'cd' : return code '0x2'
Stop.

Don't know what to do... I remember in Qt3 there used to be a graphical installer...

jacek
28th October 2006, 21:10
cannot open file '..\..\..\..\plugins\imageformats\qjpeg1.dll'
Does this file exist? Maybe you've run out of free space on disk?

durbrak
28th October 2006, 21:22
I still have 10gb of free space on my hard disk partition C: and yes, the file "C:\Qt\4.2.1\plugins\imageformats\qjpeg1.dll" does exist. But it says "..\..\..\..\plugins\imageformats\qjpeg1.dll" so I don't know from where he's trying to get the plugin, but the file definitely exists...

wysota
28th October 2006, 21:58
Maybe you have some application open which uses that file? I know it shouldn't as it is just a temporary place to store it, but it would be a good idea to check that anyway (for example by moving that file somewhere else).