Results 1 to 12 of 12

Thread: QImage -> QPixmap Issues all white on display

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Aug 2010
    Posts
    9
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default QImage -> QPixmap Issues all white on display

    I had a program working that was getting jpg images over the network loading it into a QPixmap with the loadFromData() method and assigning the QPixmap to a QLabel with setPixmap().

    The user interface was not very responsive so I decided to speed things up a little bit I by moving the jpeg decoding over to a separate thread. I found out that QPixmap couldn't run in a secondary thread so my plan was to load the data into the QImage on the secondary thread and then on the GUI thread load the QImage into the QPixmap with fromImage().

    When I did this I ended up with a white image being displayed on the screen. To verify that things were working correctly I wrote the JPEG data to a file before loading into a QImage and then had QImage save it to another file. Both of these two files have the images I expect. I even tried moving the QImage loadFromData() back to the GUI thread just to rule out threading issues.

    I know it's got to be something I'm doing wrong but it seems so straightforward. Here's the code snippet of what I'm doing.
    Qt Code:
    1. bool foobar(uchar *p_imgbuf, int img_size)
    2. {
    3. QImage image;
    4. QPixmap my_pixmap;
    5. QLabel *p_label;
    6.  
    7. p_label = new QLabel();
    8.  
    9. status = image.loadFromData(p_imgbuf, img_size,"JPG");
    10. my_pixmap.fromImage(image);
    11. p_label->setPixmap(my_pixmap);
    12. }
    To copy to clipboard, switch view to plain text mode 
    Last edited by wysota; 18th February 2012 at 09:09. Reason: missing [code] tags

Similar Threads

  1. QPixmap/QImage serious issues between Windows/Unix
    By Largo in forum Qt Programming
    Replies: 1
    Last Post: 22nd November 2011, 13:22
  2. QPixmap replace white pixels by blacks
    By bunjee in forum Qt Programming
    Replies: 1
    Last Post: 20th August 2008, 05:12
  3. DIB to QImage or QPixmap
    By ^NyAw^ in forum Qt Programming
    Replies: 0
    Last Post: 8th August 2008, 20:18
  4. issues with QImage on different computers
    By musikit in forum Installation and Deployment
    Replies: 5
    Last Post: 16th November 2007, 20:12
  5. What's faster: QPixmap-to-QImage or QImage-to-QPixmap
    By forrestfsu in forum Qt Programming
    Replies: 2
    Last Post: 15th December 2006, 17:11

Tags for this Thread

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.