Results 1 to 6 of 6

Thread: loadFromData with Pixmap probelm

  1. #1
    Join Date
    Sep 2006
    Posts
    68
    Thanks
    15
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Unhappy loadFromData with Pixmap probelm

    Hi All,

    Part of my program loads an image (a jpg) from the web and displays it on a QLabel.

    This is the important bit of code;

    Qt Code:
    1. pixmap->loadFromData( buffer->buffer() );
    2. labelIcon->setPixmap( *pixmap );
    To copy to clipboard, switch view to plain text mode 

    Now, this seems to work great on Linux, but not at all on Windows. I wrote the data in the buffer out to a file on both Linux and Windows and they are identical files. They show fine in all the image viewers I tried. I also tried with a a few different images from the web to make sure it was not a problem with onc specific image.

    Next thing I tried was writing the buffer to a temporary file and re-loading it into the pixmap using pixmap->load( filename ). This worked great on Linux, and again not on Windows.

    I know there was a similar thread before, and the conclusion was that it was a bug in QT, but when I checked that bug on the Trolls site, it was listed as Rejected (verified as working on all platforms).

    Can anyone make a suggestion as to where I am might be going wrong, or a work-around I could use to get this working in Windows?

    I tried with QT 4.3.2 and then 4.3.5 on Windows
    Am using QT 4.3.4 on Linux.

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: loadFromData with Pixmpa probelm

    What does QImageReader::supportedImageFormats() return on windows?

  3. #3
    Join Date
    Sep 2006
    Posts
    68
    Thanks
    15
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: loadFromData with Pixmpa probelm

    Oh damn. I just assumed it supported JPG since in the docs it states:

    By default, Qt can read the following formats:

    BMP
    GIF
    JPG
    JPEG
    MNG
    PNG
    PBM
    PGM
    PPM
    TIFF
    XBM
    XPM

    Hmm, going to have to figure out how to convert it of its a jpeg then I guess. Can anyone point me to some code to do JPG -> PNG conversion?
    Last edited by December; 12th June 2008 at 14:26. Reason: Spelling!

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: loadFromData with Pixmpa probelm

    Quote Originally Posted by December View Post
    Hmm, going to have to figure out how to convert it of its a jpeg then I guess. Can anyone point me to some code to do JPG -> PNG conversion?
    AFAIR the JPEG support is compiled as plugin on windows. So first check if you have the QJPEG plugin compiled. If yes, then it's just a matter of placing it imageformats subdirectory in the directory where the executable is. If not, you will have to reconfigure and recompile Qt (you can do it also to compile QJPEG into Qt).

  5. #5
    Join Date
    Sep 2006
    Posts
    68
    Thanks
    15
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: loadFromData with Pixmpa probelm

    I just tried this:

    configure -qt-libjpeg -static
    make subsrc

    But JPG is still not showing up.

    Also tried moving qjpeg4.dll into the same folder as the exe, still no JPG support.

  6. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: loadFromData with Pixmpa probelm

    Quote Originally Posted by December View Post
    configure -qt-libjpeg -static
    Hmm... I've just checked configure's options and it seems that you can't compile QJPEG into Qt anymore.

    Quote Originally Posted by December View Post
    Also tried moving qjpeg4.dll into the same folder as the exe, still no JPG support.
    Create "imageformats" subdirectory in that folder and move qjpeg4.dll there.

    Iff you use static Qt, you will have to add "QTPLUGIN += qjpeg" to your .pro file and "Q_IMPORT_PLUGIN(qjpeg)" before main().

  7. The following user says thank you to jacek for this useful post:

    December (27th July 2008)

Similar Threads

  1. finding maximum scaling of a pixmap
    By babu198649 in forum Newbie
    Replies: 1
    Last Post: 31st March 2008, 14:32
  2. empty pixmap as a QLabel
    By tommy in forum Qt Programming
    Replies: 16
    Last Post: 11th December 2007, 21:15

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.