Efficient Screen Capture

Glynn Clements glynn at gclements.plus.com
Wed Dec 20 11:27:48 PST 2006

jason cipriani wrote:

> How do I capture the contents of the screen in less than 10 seconds?
> The following code is entirely too inefficient to be useful:
> Display *disp = XOpenDisplay(NULL);
> Window win = XRootWindow(disp, XDefaultScreen(disp));
> XImage *image = XGetImage(disp, win, 0, 0, WIDTH, HEIGHT, ~0, XYPixmap);

Have you tried using ZPixmap instead? That's more likely to match the
actual framebuffer format on most modern hardware.

> I'm willing to hack it pretty far so any ideas (such as direct copies
> from video memory) would be useful. I am not willing to use any
> hardware other than this machine.
> Also just to make sure, is ~0 a sane value for plane_mask with format XYPixmap?

Yes, although it's customary to use the AllPlanes macro from Xlib.h:

	#define AllPlanes 		((unsigned long)~0L)

Glynn Clements <glynn at gclements.plus.com>

More information about the xorg mailing list