Results 1 to 4 of 4

Thread: most efficient way to get a QPixmap from a QImage

  1. #1
    Join Date
    Dec 2006
    Posts
    849
    Thanks
    6
    Thanked 163 Times in 151 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default most efficient way to get a QPixmap from a QImage

    I am rendering a page of postscript into a (png file which I load into a) QImage, then display that (by converting it into a QPixmap which I display on a QLabel).
    For an A4 page (about a million pixels) this is all very fast - except the QImage to QPixmap conversion, which I do by QPixmap::fromImage().
    Using a remote X11 connection this one step takes from 5 to 10 seconds... which is kind of annoying.

    Is there a faster way to get something drawable out of a QImage?


    Best regards
    Christoph

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: most efficient way to get a QPixmap from a QImage

    No, unfortunately not. You might go through OpenGL by converting the image to an OpenGL texture and then rendering the texture to something that can be easily converted to a pixmap but it won't change the fact that the pixmap needs to be transfered to the X server which just takes time if the pixmap is big and the server is remote.
    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.


  3. #3
    Join Date
    Dec 2006
    Posts
    849
    Thanks
    6
    Thanked 163 Times in 151 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: most efficient way to get a QPixmap from a QImage

    Ok, too bad.

    I was hoping that there might be some tricky way to speed it up
    (maybe using the fact that most parts of a (or at least my) postscript
    document are empty (i.e. white). Or by some not obvious use of some
    Flags or Format directives.

    In an alternative approach I am rendering directly into a QPixmap.
    This is way faster than going the QImage -> QPixmap way ... at least
    until you enable antialiasing. Then it is just as slow.
    Using antialising when going via QImage does not slow things (further) down.

    Maybe it is worthwhile (for antialiasing) to go the QImage way and
    split the resulting image in tiles. The drawing of completely empty tiles
    might be optimized.
    (I'd rather avoid complicating the code by different code paths for antialiasing and such, though.)

    Best regards

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: most efficient way to get a QPixmap from a QImage

    Quote Originally Posted by caduel View Post
    I was hoping that there might be some tricky way to speed it up
    Maybe you should focus on improving the client-server connection speed, e.g. by compressing the traffic between X and the client. If you're connecting through ssh, you can try issuing "ssh -Y -C" which will enable compression and trusted X11 forwarding.
    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.


  5. The following user says thank you to wysota for this useful post:

    caduel (13th June 2011)

Similar Threads

  1. How to create my own QPixmap Or QImage
    By sagirahmed in forum Newbie
    Replies: 20
    Last Post: 12th March 2019, 14:23
  2. drawing on a QPixmap or QImage
    By gren15 in forum Newbie
    Replies: 15
    Last Post: 3rd March 2009, 17:48
  3. DIB to QImage or QPixmap
    By ^NyAw^ in forum Qt Programming
    Replies: 0
    Last Post: 8th August 2008, 20:18
  4. 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
  5. QImage or QPixmap?
    By Dark_Tower in forum Qt Programming
    Replies: 9
    Last Post: 1st April 2006, 17:08

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.