Merci de ta réponse, mais je ne pense pas que cela puisse m'aider.
Car en fait mon affichage est commandé par un thread et se fait cycliquement
Je fais:
//Dans mon thread
HWND hBouton = GetDlgItem(hDlg_IHM_MAIN, IDC_IMAGE);
HDC hdc = GetDC(hBouton);
Dessiner_Image(hDlg_IHM_MAIN,hdc,&buffer);
ReleaseDC(hDlg_IHM_MAIN,hdc);
//buffer est un buffer image contenant l'image à afficher
//Ma fonction dessiner
BOOL Dessiner_Image(HWND hDlg,HDC hDC,ClsEm_CVImage *Em_Img)
{
HDC hdcMem = NULL;
HGDIOBJ hbmOld = NULL;
HBITMAP hBmp_Mem;
BITMAPINFO * pMyBitmapInfo;
BYTE * pImage;
int i;
long Hauteur_Img = Em_Img->GetImageHeight();
long Largeur_Img = Em_Img->GetImageWidth();
pMyBitmapInfo = (BITMAPINFO *) calloc(1,sizeof(BITMAPINFO) + 256 * sizeof(RGBQUAD));
// pImage = (BYTE*)calloc(1,Largeur_Img*Hauteur_Img);
// initialisation de la palette du bitmap
for ( i=0; i<256; i++)
{
pMyBitmapInfo->bmiColors[i].rgbBlue = i;
pMyBitmapInfo->bmiColors[i].rgbGreen = i;
pMyBitmapInfo->bmiColors[i].rgbRed = i;
pMyBitmapInfo->bmiColors[i].rgbReserved = 0;
}
// initialisation du header du bitmap
pMyBitmapInfo->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
pMyBitmapInfo->bmiHeader.biWidth = Largeur_Img;
pMyBitmapInfo->bmiHeader.biHeight = Hauteur_Img;
pMyBitmapInfo->bmiHeader.biPlanes = 1;
pMyBitmapInfo->bmiHeader.biBitCount = 8; // nb de bit par pixel
pMyBitmapInfo->bmiHeader.biCompression = 0; // non compressé
pMyBitmapInfo->bmiHeader.biSizeImage = 0;
pMyBitmapInfo->bmiHeader.biXPelsPerMeter = 0;
pMyBitmapInfo->bmiHeader.biYPelsPerMeter = 0;
pMyBitmapInfo->bmiHeader.biClrUsed = 256;
pMyBitmapInfo->bmiHeader.biClrImportant = 0;
hBmp_Mem = CreateDIBSection(hDC, pMyBitmapInfo, DIB_RGB_COLORS, (void**)&pImage, NULL, 0);
for (int j=0;j<Hauteur_Img;j++)
for (int i=0;i<Largeur_Img;i++)
pImage[Largeur_Img*j+i] = Em_Img->m_BufImage[Largeur_Img*(Hauteur_Img-1-j)+i];
hdcMem = CreateCompatibleDC(hDC);
hbmOld = SelectObject(hdcMem, hBmp_Mem); //selection du bitmap
BOOL test = StretchBlt(hDC,0,0,aff_x,aff_y,hdcMem,0,0,Em_Img->GetImageWidth(),Em_Img->GetImageHeight(),SRCCOPY);
BOOL test1 = DeleteDC(hdcMem);
BOOL test2 = DeleteObject(hbmOld);
BOOL test3 = DeleteObject(hBmp_Mem);
if(pMyBitmapInfo!=NULL)
{
free((void *)pMyBitmapInfo);
}
if(pImage!=NULL)
{
free((void **)&pImage);
}
}