Results 1 to 2 of 2

Thread: Computationally inexpensive (lossy) method of screenshot and/or movie?

  1. #1
    Join Date
    Apr 2012
    Posts
    38
    Thanks
    6
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Question Computationally inexpensive (lossy) method of screenshot and/or movie?

    Hello,

    I'm trying to sequentially grab screenshots and send them to a label located on the GUI. The purpose is to eventually write a program which records the screen.

    I've successfully achieved this with QPixmap's grabWindow, only it is quite slow and not very framerate friendly (I would love some 20-30fps). I've also noticed that grabWindow hides the mouse before taking a screenshot, which is a great feature usually but doesn't interest me. Also, seeing as it is a QPixmap feature, it is safe to assume that lossless (png?) screenshots are taken, which means 6meg or more per 1080p screen.

    Here is my code so far:
    Qt Code:
    1. //mw.h
    2. #include <QtGui/QMainWindow>
    3. #include <QApplication>
    4. #include <QPixmap>
    5. #include <QWidget>
    6. #include <QtGui>
    7. #include <QTimer>
    8.  
    9. namespace Ui
    10. {
    11. class mw;
    12. }
    13.  
    14. class mw : public QMainWindow
    15. {
    16. Q_OBJECT
    17.  
    18. public:
    19. mw(QWidget *parent = 0);
    20. ~mw();
    21. QTimer *derp;
    22.  
    23. public slots:
    24. void process();
    25.  
    26. private:
    27. Ui::mw *ui;
    28. };
    To copy to clipboard, switch view to plain text mode 

    Qt Code:
    1. //mw.cpp
    2. using namespace std;
    3.  
    4. mw::mw(QWidget *parent)
    5. : QMainWindow(parent), ui(new Ui::mw)
    6. {
    7. ui->setupUi(this);
    8.  
    9. derp=new QTimer;
    10. connect(derp,SIGNAL(timeout()),this,SLOT(process()));
    11. derp->start(50); //20fps
    12. }
    13.  
    14. mw::~mw()
    15. {
    16. delete ui;
    17. }
    18.  
    19. void mw::process(){
    20. ui->label->setPixmap(QPixmap::grabWindow(QApplication::desktop()->winId()).scaled(ui->label->size(),Qt::KeepAspectRatio,Qt::SmoothTransformation));
    21. }
    To copy to clipboard, switch view to plain text mode 

    What would be an alternative to lossless, CPU-intensive screenshots? Would Qt support taking jpg screenshots instead of png? Or perhaps it could be done with OpenGL somehow? Perhaps even QImageWriter?

    Thanks in advance.


    Regards,
    Mr_Cloud

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Computationally inexpensive (lossy) method of screenshot and/or movie?

    A screenshot is just pixel data, it is not in any image storage format.
    You can decide which format to save to.

    http://qt-project.org/doc/qt-5/QImag...ng-image-files

    Cheers,
    _

Similar Threads

  1. How to take ScreenShot Qt/QML
    By stereoMatching in forum Qt Quick
    Replies: 1
    Last Post: 15th June 2013, 10:47
  2. How to save screenshot?
    By xleniz in forum Qt Programming
    Replies: 1
    Last Post: 4th April 2013, 19:36
  3. Screenshot with no show
    By mpi in forum Qt Programming
    Replies: 1
    Last Post: 21st June 2011, 11:12
  4. Painting of lots of computationally heavy pixels
    By Cruz in forum Qt Programming
    Replies: 9
    Last Post: 11th April 2010, 16:35
  5. Screenshot
    By graciano in forum Qt Programming
    Replies: 3
    Last Post: 19th April 2009, 16:32

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.