GetPixel() help needed
-
Ok, I know how to use the
GetPixel
function, the only problem is that I must get the DC of an inactive/minimized window. I've triedHDC hdc = ::GetWindowDC(hwnd)
,HDC hdc = ::GetDC(hwnd)
,HDC hdc = ::LockWindowUpdate(hwnd)
, but all of them returns -1 when I call theGetPixel
function on any pixel of that DC. If I can figure this out, it would GREATLY help my project. Thanks a lot in advance ~Mike -
Ok, I know how to use the
GetPixel
function, the only problem is that I must get the DC of an inactive/minimized window. I've triedHDC hdc = ::GetWindowDC(hwnd)
,HDC hdc = ::GetDC(hwnd)
,HDC hdc = ::LockWindowUpdate(hwnd)
, but all of them returns -1 when I call theGetPixel
function on any pixel of that DC. If I can figure this out, it would GREATLY help my project. Thanks a lot in advance ~MikeYou can't get pixels from a minimized window. There is no "canvas". :) -- Seraphim Shock. Gold for your ears.
-
You can't get pixels from a minimized window. There is no "canvas". :) -- Seraphim Shock. Gold for your ears.
-
So in no way I can do this? Damn, that sucks. With this, my project would have been so great...
Not to my knowledge, no. The device context mirrors what's shown on screen. If there's nothing on screen, then there are no pixels to grab. This window you're trying to snatch pixels from.. is it in the same process as your pixel grabbing routine? If it is, you could always make the "source window" double buffered. That is, it keeps a bitmap of itself internally. That way you could access the bitmap for pixels. Otherwise it's a pretty tough job I reckon. By the way, after GetPixel() returns -1, have you checked the error code? Either call GetLastError() or add the @err pseudo-variable in the watch window in the debugger. -- Seraphim Shock. Gold for your ears.
-
Not to my knowledge, no. The device context mirrors what's shown on screen. If there's nothing on screen, then there are no pixels to grab. This window you're trying to snatch pixels from.. is it in the same process as your pixel grabbing routine? If it is, you could always make the "source window" double buffered. That is, it keeps a bitmap of itself internally. That way you could access the bitmap for pixels. Otherwise it's a pretty tough job I reckon. By the way, after GetPixel() returns -1, have you checked the error code? Either call GetLastError() or add the @err pseudo-variable in the watch window in the debugger. -- Seraphim Shock. Gold for your ears.
Well, I have a game window opened and minimized, I'm using ::FindWindow to get its HWND value, I tried all possible ways to get the window's DC, but couldn't. Would it be possible to get a bitmap or a BitBlt and get the pixel I want from it? If so, how could I do it? Thanks a lot for your help ~Mike
-
Well, I have a game window opened and minimized, I'm using ::FindWindow to get its HWND value, I tried all possible ways to get the window's DC, but couldn't. Would it be possible to get a bitmap or a BitBlt and get the pixel I want from it? If so, how could I do it? Thanks a lot for your help ~Mike
-
-
-
Uh this won't work. Sending a message to a window is not like retrieving a HDC, so it won't return the HDC of the window.
-
-
I don't think it'll work with WM_PRINT. HDCs are inprocess handles I believe (not entirely sure about that though). Sending an HDC from one process to another will at best result in nothing. I think the only way is to grab a handle to the window, and then acquire a HDC from that window handle. -- Seraphim Shock. Gold for your ears.
-
I don't think it'll work with WM_PRINT. HDCs are inprocess handles I believe (not entirely sure about that though). Sending an HDC from one process to another will at best result in nothing. I think the only way is to grab a handle to the window, and then acquire a HDC from that window handle. -- Seraphim Shock. Gold for your ears.