Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to take screen shot in Linux without X11 or /dev/fb0?

I am working on a Linux based embedded system. It uses Qt for windowing and there is no Xserver. My aim is to take screen shot of the screen.

I have tried using FBgrab. It failed since I don't have a /dev/fb0 since the frame buffer is not enabled in the kernel. We are running a Qt based application to show the UI on the screen (HDMI). I have also tried the screen shot application in the QT website which uses QPixmap and grab window. This also is a failure, since I can't run two QAppliction in the system since it affects the display.

Is there any other way to get the screen shot?

like image 228
jsaji Avatar asked Feb 09 '14 12:02

jsaji


1 Answers

You can make your application take a screenshot of itself based on some event or command. You do this by grabbing the widget to a pixmap, and then saving this pixmap somewhere. For example:

QWidget *widget = QApplication::activeWindow();
QPixmap pixmap = QPixmap::grabWidget(widget);
pixmap.save(QString("/path/to/screenshot/screenshot.png"));
like image 135
PurpleAlien Avatar answered Sep 27 '22 16:09

PurpleAlien