Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to take snapshot in linux - programmatically C++

Tags:

c++

linux

qt

I am currently involved in a project which requires me to repeatedly take snapshots of the screen. I am using qt's grabScreen function to do the same. The screen freezes for half a second every time the program takes a snapshot causing the computer to seem to be very slow :(

Can anybody suggest me a better method of doing this ?

like image 391
Anuvrat Parashar Avatar asked May 11 '10 20:05

Anuvrat Parashar


People also ask

How to take screenshot using Script?

Shift + Alt + PtrScr: This shortcut captures the active window and copies it to the clipboard. Shift + PtrScr: This shortcut capture a specific area to the clipboard. Alt + PtrScr: This shortcut will capture the active window and save it to Pictures.

How to take screenshot using unix command?

Use the shortcut keys PrintScreen to capture the whole desktop and Alt+PrintScreen to capture the current window (these also work under Windows). Or select Applications -> Accessories -> Screenshot from the menus. Or type xfce4-screenshooter from the command line. xfce4-screenshooter -f will capture the whole desktop.


2 Answers

If you're OK with doing it in lower level manner, then you should look into one of those xorg tools that I can't remember the name of. It's installed by default and outputs the screenshot in a bitmap format. It's a shame I can't remember the name.

EDIT: I got it! It's "xwd". Cheers.

like image 188
Andreas Avatar answered Sep 29 '22 01:09

Andreas


You could look at the source of, say, ksnapshot which is the Qt-based KDE app doing this. Its SVN archive is here.

like image 35
Dirk Eddelbuettel Avatar answered Sep 29 '22 02:09

Dirk Eddelbuettel