Results 1 to 12 of 12

Thread: QImage -> QPixmap Issues all white on display

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,376
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Thanks
    4
    Thanked 5,019 Times in 4,795 Posts
    Wiki edits
    10

    Default Re: QImage -> QPixmap Issues all white on display

    I will repeat my unanswered questions then:

    • How do you run this method?
    • So you got rid of all the threads?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  2. #2
    Join Date
    Aug 2010
    Posts
    9
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QImage -> QPixmap Issues all white on display

    Gotha, somehow I must have missed those original questions.
    - In this code yes everything is running on the main GUI thread (for solving this problem). The code which collects up the UDP packets into a frame runs on a separate thread and sends a signal that the frame is complete with an index of the frame inside the buffer pool.
    - When the slot is received (on the main GUI thread, I verified this with the debugger, and there are no messages that the QPixmap can't be used on the non gui thread) it calls a method to get the address of the buffer and the length (yes they are protected by a mutex), it then calls the routine which i provided a snippet from. When this routine finishes the caller release the buffer so the secondary thread can reuse it.

    I just tried something else today. After I load the QImage from the buffer I call QImge.isNull() which returns false. After I convert the QImage to the QPixmap I call QPixmap.isNull() and it returns true. So something is going wrong with that conversion, even through QPixmap.fromImage() is returning true.

  3. #3
    Join Date
    Aug 2010
    Posts
    9
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QImage -> QPixmap Issues all white on display

    I figured out what the problem was. Somehow I didn't see that fromImage was a static member so my code was bogus
    my_pixmap.fromImage(image); should have been my_pixmap = QPixmap::fromImage(image);

  4. #4
    Join Date
    Sep 2011
    Location
    Manchester
    Posts
    538
    Qt products
    Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows
    Thanks
    3
    Thanked 106 Times in 103 Posts

    Default Re: QImage -> QPixmap Issues all white on display

    I wonder why do you use QImage as a temporary data container?
    Wouldn't it be easier and faster to use QByteArray to store the data and load it directly to QPixmap?

  5. #5
    Join Date
    Aug 2010
    Posts
    9
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QImage -> QPixmap Issues all white on display

    Because my original goal was to do the JPEG decoding on a secondary thread. QPixmap cannot run on a secondary thread but QImage can. Therefore I load (which does the decode) QImage on the secondary thread, then let QPixmap render the image on the GUI thread.

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
  •  
Qt is a trademark of The Qt Company.