Salut,
Je veux lire la valeur RGB d'un pixel avec GetDIBits. J'ai pris un code que j'ai vu plusieurs fois sur le forum. Tout marche sauf quand je veux savoir la valeur dans mon tableau lbBits je reçois toujours 0.
Si quelqu'un peux m'aider c'est apprécier.
Voici mon code :
//je pars d'un boutton
HDC hdc;
hdc = CreateDC("DISPLAY", 0, 0, 0);
//je crée le bitmap à partir du hdc
int dwWidth, dwHeight;
dwWidth = GetDeviceCaps(hdc, HORZRES);
dwHeight = GetDeviceCaps(hdc, VERTRES);
HBITMAP hbmp = CreateCompatibleBitmap(hdc, dwWidth, dwHeight);
//j'appelle ma fonction d'analyse de l'image
AnalyseDIB(hbmp);
//la fonction en question
int AnalyseDIB(HBITMAP hbmp)
{
int RED, GREEN, BLUE, x, y;
BITMAP bmp;
GetObject(hbmp, sizeof(BITMAP), &bmp);
LPBYTE lpBits = new BYTE[4*bmp.bmWidth*bmp.bmHeight];
//structure bitmapinfo
BITMAPINFO bi;
memset(&bi, 0, sizeof(BITMAPINFO));
bi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
bi.bmiHeader.biWidth = bmp.bmWidth;
bi.bmiHeader.biHeight = bmp.bmHeight;
bi.bmiHeader.biBitCount = 32;
bi.bmiHeader.biPlanes = 1;
bi.bmiHeader.biCompression = BI_RGB;
// récupération pixels
HDC hdc = GetDC(NULL);
x = GetDIBits(hdc, hbmp, 0, bmp.bmHeight, lpBits, &bi, DIB_RGB_COLORS);
ReleaseDC(NULL, hdc);
//et là je bloque, toujours une valeur de zéro :
RED = lpBits[500];//le chiffre 500 est pris au hasard
//j'affiche dans un message box et j'ai toujours zéro 
Quelqu'un comprend pourquoi?
Merci