Bonjour,

Voilà, j'utilise la bibliothèque openCV dans mon application MFC, mon problème c'est d'afficher une image de type (IplImage) dans une picture control, j'ai trouvé un code sur un forum japonnais qui marche très bien, mais seulement lorsque j'utilise une boite de dialogue, alors que moi Je veux afficher cette image directement sans utiliser la boite de dialog.

--------------------------------------------------------------
voici le 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
IplImage *img;
	img = cvLoadImage(path); 

	char* ColorBuf = (char*)calloc( sizeof(char), img->width * img->height * 4 );
	CBitmap mbmp;

	for( int y = 0; y < img->height; y++ ) 
	{
		for( int x = 0; x < img->width; x++ ) 
		{
		ColorBuf[ y * img->width * 4 + x * 4 + 0 ] =
		img->imageData[ y * img->widthStep + x * 3 + 0 ];
		ColorBuf[ y * img->width * 4 + x * 4 + 2 ] =
		ColorBuf[ y * img->width * 4 + x * 4 + 1 ]=
		ColorBuf[ y * img->width * 4 + x * 4 + 0 ];
		}
	}
	mbmp.CreateBitmap( img->width, img->height, 1, 32, ColorBuf );
	free( ColorBuf );

	((CStatic*)GetDlgItem( IDC_STATIC_PICTURE ))->SetBitmap ( mbmp );
-------------------------------------------------------------------------

Merci pour votre aide.