bonjours a tous,

j'essai d'utiliser les fonciton de X11 pour afficher une image dans une fenetre,

j'ai trouver quelque petit truk, masi je n'arrive pas a bien les adapter et ej ne sait pas pourquoi..voici mon code :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
 
 
 
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <stdio.h>
#include <stdlib.h>
#include "stat.h"
#include <sys/types.h>
 #include <unistd.h>
  #     include <sys/mman.h>
 
 
int main()
{
Display * display;
Window   window;
Screen *ecran;
XImage *image;
FILE *f;
int x=0,y=0,popo1;
char *buffer=NULL;
int running = 1;
struct stat buf;
XEvent event;	
 
	printf("bug");
 
if (XInitThreads() == 0)    {
 printf("Error : initializing XInitThreads.\n" );
 return 1;
}
 
 
display = XOpenDisplay(NULL);
 
 
		if (display == NULL) 
		{
		printf("Error : Cannot open display.\n" );
		}
 
//ecran= DefaultScreenOfDisplay(display);
 
window = XCreateSimpleWindow(display,XDefaultRootWindow(display),0,0,800,600,0,0,0);
XSelectInput(display,window,ExposureMask | ButtonPressMask | ButtonReleaseMask | KeyPressMask );
XMapWindow(display,window);
// charger l'image 
 
 
	f = fopen("decompressedbmp.bmp","rb" );
		if (f == NULL) 
		{
		printf("Error : loading image.\n" );
		}
	else 
	{
 
	popo1=fileno(f);
 
	fstat(popo1,&buf);
 
	buffer=malloc(buf.st_size);
	buffer=mmap((caddr_t)0,buf.st_size,PROT_EXEC|PROT_READ,MAP_SHARED,popo1,0);
 
	}
 
 
 
 if (buffer) {
  image = XCreateImage(display, DefaultVisual(display,DefaultScreen(display)),24,ZPixmap,0,buffer,384,288,8,0);
 }
 
while (running) 
{
 
 XNextEvent(display,&event);
  switch (event.type) {
   case ButtonPress :
   if (image) {
    XLockDisplay(display);
    XPutImage(display,window,DefaultGC(display,DefaultScreen(display)),image,0,0,event.xbutton.x,event.xbutton.y,384,288);
    XSync(display,0);
    XUnlockDisplay(display);
   }
   break;
   case KeyPress :
   running = 0; // quitter
   break;
  }
 }
 
 if (image) {
  XDestroyImage(image);
 }
 XUnmapWindow(display,window);
 XDestroyWindow(display,window);
 
 return 0;
 }
j'ai bien le screen mais il n'est pas remplit et vide, et je n'arrive pas a faire bouger la fenetre...enfin plein de petit bug, je doit avoir loupé quelque notion d'affichage..Pouvez vous m'éclairer svp ?
Mon image d'entrer est un bmp 24 bit.
Merci.