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.
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