What functions would one use to take a screenshot of an X11 desktop, using the Xlib library? I would prefer a method that's more efficient than getting individual pixels. Thanks.
Asked
Active
Viewed 3,147 times
1 Answers
7
The standard tool for taking screenshots in X11 is to use
xwd -root > myscreen.xwd
Then, convert to .pnm with
xwd2pnm myscreen.xwd > myscreen.pnm
Therefore, you can locate the source code of xwd and see how it is implemented, http://cvsweb.xfree86.org/cvsweb/xc/programs/xwd/xwd.c?rev=HEAD&content-type=text/vnd.viewcvs-markup

user597630
- 553
- 3
- 11
-
Thanks. It seems like it uses XmuClientWindow to take the actual screenshot, which is an X11 extension. – slartibartfast Mar 14 '11 at 00:38
-
1@myrkos: That's a function for finding windows. Screen dumping is done with the `XGetImage` function. – Donal Fellows Mar 14 '11 at 08:50
-
1It's not that different, but the source for the xwd shipped in current distros is at: http://cgit.freedesktop.org/xorg/app/xwd/tree/ – alanc Mar 14 '11 at 16:42