|
接着前帖 http://www.linuxfans.org/nuke/modules.php?name=Forums&file=viewtopic&t=148585
屏幕是抓到了,但是利用XpmCreateDataFromImage生成的Xpm数据,却不能被gdk_pixbuf_new_from_xpm_data使用,提示“Inline XPM data is broken”。感觉不应该啊?
code如下:
[code:1]Window desktop;
Display *dsp;
XImage *img;
int w,h;
char **data ;
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);
XpmCreateDataFromImage(dsp, data, img, NULL, NULL);
pixbuf1 = gdk_pixbuf_new_from_xpm_data(data);
if (pixbuf1 == NULL) {
g_print ("Can't load image \n !!");
}
XDestroyImage(img);
XCloseDisplay(dsp);
[/code:1] |
|