Results 1 to 12 of 12

Thread: Take a screenshot and convert it to PNG but FAST !

  1. #1
    Join Date
    Oct 2009
    Posts
    38
    Thanks
    13
    Platforms
    Unix/X11 Windows

    Default Take a screenshot and convert it to PNG but FAST !

    Hi there!

    My program takes screenshots using QPixmap::grabWindow(); then I convert it to PNG.

    However the convertion is very slow (about 1 sec) and I need it to be much faster than that.

    Any idea


    In fact, I think that if I can capture the screen directly as a PNG, it would be great but I don't know how to do that.

  2. #2
    Join Date
    Jan 2009
    Posts
    3
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Take a screenshot and convert it to PNG but FAST !

    have you checked screenshot example present in Qt Source code Qt/4.x.x/examples/desktop/screenshot

  3. #3
    Join Date
    Oct 2009
    Posts
    38
    Thanks
    13
    Platforms
    Unix/X11 Windows

    Default Re: Take a screenshot and convert it to PNG but FAST !

    Actually I know how to take a screenshot.

    I now want to convert it to PNG quickly.

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,360
    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: Take a screenshot and convert it to PNG but FAST !

    Convert it from what?
    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. #5
    Join Date
    Jan 2009
    Posts
    3
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Take a screenshot and convert it to PNG but FAST !

    from pixmap to png

    QString format = "png";
    Pixmap.save(fileName, format.toAscii());

  6. #6
    Join Date
    Oct 2009
    Posts
    38
    Thanks
    13
    Platforms
    Unix/X11 Windows

    Default Re: Take a screenshot and convert it to PNG but FAST !

    Quote Originally Posted by harish.surana View Post
    from pixmap to png

    QString format = "png";
    Pixmap.save(fileName, format.toAscii());
    Yes from Pixmap to PNG, but what I said is that this method is to slow ! (pixmap.save())

    Is there any other way to take a screenshot and convert it to PNG QUICKLY ?

  7. #7
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,360
    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: Take a screenshot and convert it to PNG but FAST !

    Quote Originally Posted by fitzy View Post
    Is there any other way to take a screenshot and convert it to PNG QUICKLY ?
    Yes, switch to Windows, QPixmap::toImage() is a no-op there. BTW. You don't convert it from pixmap to png, you convert it from pixmap to image and then save it as png.
    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.


  8. #8
    Join Date
    Oct 2009
    Posts
    38
    Thanks
    13
    Platforms
    Unix/X11 Windows

    Default Re: Take a screenshot and convert it to PNG but FAST !

    Quote Originally Posted by wysota View Post
    Yes, switch to Windows, QPixmap::toImage() is a no-op there. BTW. You don't convert it from pixmap to png, you convert it from pixmap to image and then save it as png.


    You're right, but which function should I use ?

  9. #9
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,360
    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: Take a screenshot and convert it to PNG but FAST !

    Quote Originally Posted by fitzy View Post
    You're right, but which function should I use ?
    I don't understand your question. What function do you mean? Are you sure you understood my last reply?
    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.


  10. #10
    Join Date
    Oct 2009
    Posts
    38
    Thanks
    13
    Platforms
    Unix/X11 Windows

    Default Re: Take a screenshot and convert it to PNG but FAST !

    I'm sorry, here is what I meant :

    Quote Originally Posted by wysota View Post
    You don't convert it from pixmap to png, you convert it from pixmap to image and then save it as png.
    my answer :
    Quote Originally Posted by fitzy View Post
    You're right.
    ---

    Quote Originally Posted by wysota View Post
    Yes, switch to Windows, QPixmap::toImage() is a no-op there. BTW.
    You are talking about win32, right ? If you do, which specific function should I use ?

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

    Default Re: Take a screenshot and convert it to PNG but FAST !

    if I understood that correctly:
    use QPixmap::toImage(). It just happens to be fast on windows because there is nothing (or not much) to do internally. For you as a Qt user you always do grabWindow(), then QPixmap::toImage(), then QImage::save().

    (This sequence just happens to be faster on the windows platform.)

  12. #12
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,360
    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: Take a screenshot and convert it to PNG but FAST !

    Quote Originally Posted by caduel View Post
    if I understood that correctly:
    use QPixmap::toImage(). It just happens to be fast on windows because there is nothing (or not much) to do internally. For you as a Qt user you always do grabWindow(), then QPixmap::toImage(), then QImage::save().
    That's exactly what I meant - QPixmap::toImage() is a no-op on Windows. It's probably a no-op if you use the raster painting engine on X11 as well but I'm not sure of that.
    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.


Similar Threads

  1. How to draw a widget directly on the frame buffer
    By kapoorsudhish in forum Qt Programming
    Replies: 8
    Last Post: 12th November 2009, 06:59
  2. Take a screenshot of a QGraphicsRectItem
    By yazwas in forum Qt Programming
    Replies: 1
    Last Post: 12th October 2009, 13:14
  3. Replies: 7
    Last Post: 26th June 2009, 19:33
  4. Screenshot
    By graciano in forum Qt Programming
    Replies: 3
    Last Post: 19th April 2009, 16:32
  5. Custom widget directly from .ui
    By blelump in forum Qt Tools
    Replies: 2
    Last Post: 1st September 2008, 23:05

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.