-
GetPixel Problem
PHP Code:
HDC bitmapDC;
HBITMAP bitmapHandle;
COLORREF bmpSample;
bitmapHandle=(HBITMAP)LoadImage(0,"e:\\mytestsample.bmp",IMAGE_BITMAP,0,0,LR_LOADFROMFILE);
bitmapDC = GetDC((HWND)bitmapHandle);
bmpSample = GetPixel(bitmapDC, 23, 31);
cout << "aaa " << bmpSample << '\n';
I get a 9 digit value for bmpSample lol.
-
this question belongs on the windows board...
// bitmapDC = GetDC((HWND)bitmapHandle);
first of all, why are you casting an HBITMAP to HWND? their completely incompatible types. you need to create a compatible device context with the one you'll be drawing to (in this case, the screen), then select the bitmap into it.
Code:
HDC sdc = GetDC(NULL); // ie: the screen
HDC cdc = CreateCompatibleDC(sdc);
SelectObject(cdc, bmp);
-
Moved to the Windows board.
-
Maybe if you can put bitmapHandle in a static control..you can use correctly GetPixel