Skip to main content
gamedev.net
🔒 Locked

Windows API Pixel Retrieval

Started by Funkymunky 5 replies 300+ views
Original Post
Funkymunky
Funkymunky
I want to get a pixel from the current screen being displayed. Is this the window you get with a call to GetDesktopWindow()? I tried using a GetPixel with an HDC derived from a call to it, but it doesnt seem to work correctly. I don''t want to end up using GetPixel though, what I really want to know is a super fast way to get a pixel from the currently display screen. All help is appreciated.
Steel
Steel
quote:
I want to get a pixel from the current screen being displayed.


Do you want a pixel from the current screen or the active window? I'll assume you stated it correctly and are trying to get a pixel from the current screen.

Use GetPixel() like you were, but instead of using GetDesktopWindow() to retriece a HDC, use GetDC() and pass NULL/zero to retrieve the DC of the screen.


HDC hdcScreen = GetDC(0);
COLORREF rgbValue = GetPixel(hdcScreen, x, y);


In answer to the first question, GetDesktopWindow() gets the DC for the Desktop (which is technically a window by all respects).

quote:
I don't want to end up using GetPixel though, what I really want to know is a super fast way to get a pixel from the currently display screen.


"super fast" just won't happen with Windows GDI.

Edited by - Steel on October 15, 2000 2:19:22 PM
Funkymunky
Funkymunky
If I use DirectDraw, I''ll have to first copy the screen to a surface and then get the pixel? I''m pretty sure that''d be slower. Even with assembly there''s no fast way? It doesn''t have to use the Windows API, it just has to be able to read from the screen displayed by Windows.
DekuTree64
DekuTree64
In DDraw, you''d just lock the primary surface and read the pixel from it. Locking takes a while though, so if you''re not doing anything else to the surface after you get the pixel, it wouldn''t be much faster.



-Deku-chan

DK Art (my site, which has little programming-related stuff on it, but you should go anyway^_^)

"I'm dropping like flies!" - me, playing Super Smash Bros. (and losing)
"What fun!" - me, playing Super Smash Bros. (and beating the crap out of somebody)
IOFILE
IOFILE
Oops, forgot to put my name, that was from me. Sorry guys
IOFILE

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.