|
发表于 2004-12-22 04:22:10
|
显示全部楼层
写了个简单例子
[code:1]
#include <X11/Xlib.h>
#include <X11/xpm.h>
#include <X11/Xutil.h>
main()
{
Window desktop;
Display *dsp;
XImage *img;
int w,h;
dsp=XOpenDisplay(NULL);
if(!dsp)
{
printf("XOpenDisplay error\n");
return;
}
desktop=RootWindow(dsp,0);
if(!desktop)
{
printf("cannot get root window\n");
return;
}
w=DisplayWidth(dsp,0);
h=DisplayHeight(dsp,0);
img=XGetImage(dsp,desktop,0,0,w,h,~0,ZPixmap);
XpmWriteFileFromImage(dsp,"./screenshot.xpm",img,NULL,NULL);
XDestroyImage(img);
XCloseDisplay(dsp);
}
[/code:1] |
|