1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
| #include <stdlib.h>
#include <stdio.h>
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <time.h>
#define BLACK XBlackPixel(display,screen)
#define WHITE XWhitePixel(display,screen)
#define ROOT XDefaultRootWindow(display)
#define HEIGHT DisplayHeight(display,screen)
#define WIDTH DisplayWidth(display,screen)
int main()
{
sleep(3);
Display* display;
Window win2;
XImage* img;
XEvent ev;
GC gc;
int screen;
display = XOpenDisplay(NULL);
if (display == NULL)
{
printf ("!Open Display \n");
exit -1;
}
screen = *(int*)DefaultScreenOfDisplay(display);
gc=DefaultGC(display,screen);
printf ("Debut GET @ %ld \n",time(NULL));
img = XGetImage(display,ROOT,0,0,WIDTH,HEIGHT,AllPlanes,XYPixmap);
printf ("Fin GET @ %ld \n",time(NULL));
win2 = XCreateSimpleWindow(display,ROOT,0,0,WIDTH,HEIGHT,0,BLACK,WHITE);
XSelectInput(display,win2,ExposureMask);
XMapWindow(display,win2);
while(1)
{
XNextEvent(display,&ev);
if (ev.type == Expose)
break;
}
printf ("Debut Put @ %ld \n",time(NULL));
XPutImage(display,win2,gc,img,0,0,0,0,WIDTH,HEIGHT);
printf ("FIN Put @ %ld \n",time(NULL));
XDestroyImage(img);
XDestroyWindow(display,win2);
XCloseDisplay(display);
return 0;
} |
Partager