QImage load JPEGs not working - Qt4.6.3, QtCreator2.0, Ubuntu 9.8



  • Hello friends,

    I am trying to get JPEG image loading working in QtCreator2.0, Qt4.6.3, Ubuntu 9.8. Basically I am just calling QImage.load() and trying to draw the image using the QPainter. It just doesn't display any image when the file type is JPEG. When I convert the file to PNG it works fine.

    I am getting the snap shot images from a video camera that only creates JPEG format stills.

    Thank you.



  • Are there any ... error messages in Application console log? Can you check?



  • Do you mean the Application Output window? If so there is one error there:

    &"Warning: GDB: Failed to set controlling terminal: Invalid argument \n"



  • Yep. Hmmm...

    As I recall, the QT library, by default, building with "-system-libjpeg". I.e. "Use libjpeg from the operating system". Perhaps you have no jpeg library.

    Please, put in your code
    qDebug() << QImageReader::supportedImageFormats ();
    and check Application output



  • Application output is:

    ("bmp", "pbm", "pgm", "png", "ppm", "xbm", "xpm")

    How can I add jpg support?

    Thank you.



  • I tried to install the latest version of libjpeg-dev and I get a message that I already have the latest version:

    user1@user1-desktop:~$ sudo apt-get install libjpeg-dev
    Reading package lists... Done
    Building dependency tree
    Reading state information... Done
    Note, selecting libjpeg62-dev instead of libjpeg-dev
    libjpeg62-dev is already the newest version.
    The following packages were automatically installed and are no longer required:
    linux-headers-2.6.31-14 linux-headers-2.6.31-14-generic
    Use 'apt-get autoremove' to remove them.
    0 upgraded, 0 newly installed, 0 to remove and 2 not upgraded.



  • This is a good question :)

    1. How did U install Qt?
    2. As far as I understood, any case, qt uses its own plugin to work with jpeg. But building configuration may deny to build plugin, for example, it is key "-no-jpeg". Perhaps, QT didn't find jpeg library...
      On my pc, qt image plugins are in
      /usr/lib/qt4/plugins/imageformats
      There are
      libqgif.so libqico.so libqjpeg.so libqmng.so libqsvg.so libqtiff.so

    Where is TROLL to explain this situation :)



  • I installed Qt via the latest download(Open Source Qt 4.6.3 & Qt Creator 2.0) from qt.nokia.com.

    I checked my usr/lib/qt4/plugins/imageformats location and it has the same plugins you mentioned.



  • set the environment variable QT_DEBUG_PLUGINS, e.g.

    export QT_DEBUG_PLUGINS=1

    then run your app. Check the debug output for errors.



  • I've also got the same problem.

    If it makes any difference I've built a number of different versions of qt from 4.5 to 4.6.3 and it has never worked for me. I compile Qt using visual studio 2005 in Windows 7. Although I could download the built libraries from the website I need sqlite support and as such I need to recompile.

    Following the previous post I've found this errors between a lot more making references to other image plugins.

    QFactoryLoader::QFactoryLoader() looking at "C:/Qt/32bitVSSQL/qt/plugins/imageformats/libqjpeg4.a"
    "The file 'C:/Qt/32bitVSSQL/qt/plugins/imageformats/libqjpeg4.a' is not a valid Qt plugin."
    not a plugin

    and then

    QFactoryLoader::QFactoryLoader() looking at "C:/Qt/32bitVSSQL/qt/plugins/imageformats/qjpeg4.dll"
    In C:/Qt/32bitVSSQL/qt/plugins/imageformats/qjpeg4.dll:
    Plugin uses incompatible Qt library
    expected build key "Windows msvc debug full-config", got "Windows mingw release full-config"
    "The plugin 'C:/Qt/32bitVSSQL/qt/plugins/imageformats/qjpeg4.dll' uses incompatible Qt library. Expected build key "Windows msvc debug full-config", got "Windows mingw release full-config""
    not a plugin

    Does anybody have some idea? That's something that has been bugging me for a long time.



  • MinGW and MSVC have different ABIs, you can't load plugins generated with one compiler into an app generated with the other compiler.



  • Well, that's why I recompiled qt from visual studio. Shouldn't the standard configuration compile also the image formats plugins?



  • bq. Well, that’s why I recompiled qt from visual studio. Shouldn’t the standard configuration compile also the image formats plugins?

    That depends on you configuration, make sure Qt was configured with JPEG support. Could it be that you tried building with MSVC in the same directory where you already had a MINGW build, and for some reason, JPEG was disabled in your build? That'll leave stale plugins, which won't load in your newly built Qt.



  • I'm getting the same problem on Ubuntu 10.04. QtCreator 4.7.1
    Here are details.
    http://www.windyweather.net/wp/2011/03/03/qt-4-7-on-ubuntu-lucid-not-loading-jpg-image-plugin/

    Program sources are available, of course.
    Works fine on a system where the tools are installed. On a target system without Qt SDK, libqtcore4 and libqtgui4 packages are installed. Plugins are where the program expects them to be, but only the PNG images work, not JPG images. [haven't checked other formats.]

    Build system is x86 and target system is x64 if that matters.
    Details contains screen shots of plugin folders, lib paths and supported image formats.

    it says JPG is supported, but program will not load JPG images.

    Is this a bug between x86 and x64 systems?
    Using x86 build and x64 target works fine on Windows system, but plugins are manually moved in that case rather than using package install.
    I'm trying to figure out how to package this program for Deb/Ubuntu systems and I have to get it to work first on system without SDK installed.

    Do we know what I missed, or is this a bug?

    Thanks,
    Windy



  • Same problem with SDK 1.1.4 .

    I'm trying this code:
    @
    QImage image;
    qDebug() << QImageReader::supportedImageFormats ();
    image.load("/home/luca/immagini_vscam/T0-20111122-223411510.jpg");
    qDebug() << image.height();
    @

    but while running I get a "segmentation fault".

    The supported formats are:
    @
    ("BW", "EPS", "EPSF", "EPSI", "EXR", "PCX", "PSD", "RAS", "RGB", "RGBA", "SGI", "TGA", "XCF", "bmp", "bw", "dds", "eps", "epsf", "epsi", "exr", "gif", "ico", "jp2", "jpeg", "jpg", "mng", "pbm", "pcx", "pgm", "pic", "png", "ppm", "psd", "ras", "rgb", "rgba", "sgi", "svg", "svgz", "tga", "xbm", "xcf", "xpm", "xv")
    @

    I have libjpeg 8 installed in my system and my application is linked to it:
    @
    ldd my_app
    linux-gate.so.1 => (0xffffe000)
    ...
    ...
    libjpeg.so.8 => /usr/lib/libjpeg.so.8 (0xb4991000)
    libpng14.so.14 => /usr/lib/libpng14.so.14 (0xb496a000)
    libtiff.so.3 => /usr/lib/libtiff.so.3 (0xb4910000)
    ...
    ...
    libphonon.so.4 => /home/luca/QtSDK/Desktop/Qt/474/gcc/lib/libphonon.so.4 (0xb2f78000)
    libQtDBus.so.4 => /home/luca/QtSDK/Desktop/Qt/474/gcc/lib/libQtDBus.so.4 (0xb2ef0000)
    libQtXml.so.4 => /home/luca/QtSDK/Desktop/Qt/474/gcc/lib/libQtXml.so.4 (0xb2ea5000)
    @



  • I solved by compiling from source the Qt 4.7.4 libraries.

    Now I can use jpeg without problem.



  • Hi everyone!
    Maybe it would be useful. Problem may be in path to image. Just by adding ":" a got my image to display. E.g.: "images/pic.jpg" -> ":images/pic.jpg".


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.