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
|
HBITMAP hBmp;
LPSTR lpszFileName;
COLORREF dwPixel;
HDC hDC;
BITMAP BMPObj;
//Chargement de l'image BMP
hBmp=LoadImage(NULL,lpszFileName,IMAGE_BITMAP,0,0,LR_CREATEDIBSECTION|LR_LOADFROMFILE);
//On recupère les infos du BMP
GetObject(hBmp,sizeof(BITMAP),&BMPObj);
//Infos : BMPObj.bmWidth = Largeur
// BMPObj.bmHeight = Hauteur
// BMPObj.bmBitsPixel = Bits par pixel
//Pour + d'infos cf MSDN
//Device context pour acceder au contenu de l'image
hDC=CreateCompatibleDC(NULL);
//Selection du BMP
SelectObject(hDC,hBmp);
//Pixel à x,y
//COLORREF : pixel sous la forme 0x00BBGGRR
dxPixel=GetPixel(hDC,x,y);
//Libère le DC
DeleteDC(hDC);
//Libère le BMP de la mem
DeleteObject(hBmp); |