Results 1 to 13 of 13

Thread: Render from a thread into a pixmap?

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Sep 2007
    Location
    Berlin, Germany
    Posts
    17
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Thanks
    2
    Thanked 1 Time in 1 Post

    Default Re: Render from a thread into a pixmap?

    I combine up to nine RGB-images with a resolution of 256x256 each to one large image. I want to do this depending on user interaction multiple times a second. The combined QImage is created in the "worker" thread and gets converted to a pixmap in the GUI thread (by calling QPixmap::fromImage()). Here I draw it on the screen. The conversion from QImage to QPixmap with a resolution of eg 768x768 is the slowest operation I think.

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,373
    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: Render from a thread into a pixmap?

    If you do it several times a second, I suggest you draw it to the screen without composing it first on an offscreen bitmap. Or even use OpenGL.

  3. #3
    Join Date
    Sep 2007
    Location
    Berlin, Germany
    Posts
    17
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Thanks
    2
    Thanked 1 Time in 1 Post

    Lightbulb Re: Render from a thread into a pixmap?

    Quote Originally Posted by wysota View Post
    If you do it several times a second, I suggest you draw it to the screen without composing it first on an offscreen bitmap. Or even use OpenGL.
    Currently I am playing with the QCoreApplication::processEvents() you mentioned. I think this could solve my problem. I am not using OpenGL, bacause the application should also run on Qtopia devices...

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

    Default Re: Render from a thread into a pixmap?

    Quote Originally Posted by rage View Post
    The conversion from QImage to QPixmap with a resolution of eg 768x768 is the slowest operation I think.
    It could be, but you have said that drawing on QImage is slower than drawing on QPixmap. Have you tried to use a profiler to check the times?
    Last edited by jacek; 20th December 2007 at 14:26. Reason: typo

  5. #5
    Join Date
    Sep 2007
    Location
    Berlin, Germany
    Posts
    17
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Thanks
    2
    Thanked 1 Time in 1 Post

    Default Re: Render from a thread into a pixmap?

    Quote Originally Posted by jacek View Post
    I could be, but you have said that drawing on QImage is slower than drawing on QPixmap. Have you tried to use a profiler to check the times?
    Yes, I have done that with callgrind. The fromImage() call takes ~44% of the processing time.

  6. #6
    Join Date
    Sep 2007
    Location
    Berlin, Germany
    Posts
    17
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Thanks
    2
    Thanked 1 Time in 1 Post

    Default [SOLVED] Render from a thread into a pixmap?

    Thanks wysota!
    I'm now rendering the QPixmap within the GUI thread, so I don't need QImages. By calling processEvents() it doesn't block. I'll just have to do some locking with mutexes and then everything should be fine!

  7. #7

    Default Re: Render from a thread into a pixmap?

    How rendering the QPixmap within the GUI thread? And how to do it won't be block?Would you mind write your handle?Thanks

  8. #8
    Join Date
    Jan 2008
    Location
    Poland
    Posts
    687
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Thanks
    4
    Thanked 140 Times in 132 Posts

    Default Re: Render from a thread into a pixmap?

    I would like to be a "Guru"

    Useful hints (try them before asking):
    1. Use Qt Assistant
    2. Search the forum

    If you haven't found solution yet then create new topic with smart question.

Similar Threads

  1. Client/Server Error: BadIDChoice
    By 3nc31 in forum Qt Programming
    Replies: 5
    Last Post: 27th November 2007, 11:22
  2. KDE/QWT doubt on debian sarge
    By hildebrand in forum KDE Forum
    Replies: 13
    Last Post: 25th April 2007, 07:13
  3. Replies: 10
    Last Post: 20th March 2007, 23:19
  4. Problem closing a QMainWindow in Qt4.2
    By ian in forum Qt Programming
    Replies: 11
    Last Post: 17th October 2006, 01:49
  5. [QT4] QThread and printing a QList<QPixmap>
    By KShots in forum Qt Programming
    Replies: 3
    Last Post: 24th April 2006, 22:44

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.