How to Take Screenshot of Obscured Window in C++ on Linux

Taking a screenshot of a window in C using only the X11 lib

You will manually have to get color values of all the pixels and then convert it to a format of your choice.
AFAIK, there is no "simple" way to do it.

You can check with this question here: How do take a screenshot correctly with xlib?

Fastest method for screen capturing on Linux

This is possible using VirtualGL in a server with hardware acceleration. Basically just configure the server appropiately, then either on the same machine or on a machine in the same network, run

export DISPLAY=<your xvfb display>
vglrun <your_app>

This will have the following advantages:

1) your app will render using virtualGL, which will use the hardware

2) VirtualGL will display your 3D context inside the Xfvb display, which will only render the 2D widgets in CPU

3) configure Xvfb to render to a framebuffer

4) profit!

Screen Capture Specific Window

Yes it is. All what you need is get handle to window which you want to capture and use WinAPI function PrintWindow for example:

// Get the window handle of calculator application.
HWND hWnd = ::FindWindow( 0, _T( "Calculator" ));

// Take screenshot.
PrintWindow( hWnd, getDC(hWnd), 0 );

Here you have PrintWindow documentation.

How to take screen shot of whole desktop without background/wallpaper picture in Windows

Disabling the wallpaper is going to cause an annoying flicker/redraw. I expect, anyway.
It would be cleaner to enumerate all of the windows on the desktop that are visible, find their dimensions/position, and then determine the area outside of all of those rectangles. Make that area invisible. i.e. white, to save paper when printing, or another color to suit your purpose. This answer is just to describe the general approach, but I think it's the way to go, unless some magic "silver bullet" appears.



Related Topics



Leave a reply



Submit