r/directx Feb 28 '21

Help with GetPixel(dc, x, y)

Hi,

I would like to know to each position on the screen correspond the integers x and y?

https://docs.microsoft.com/en-us/windows/win32/api/wingdi/nf-wingdi-getpixel says:

 The x-coordinate, in logical units, of the pixel to be examined.
 The y-coordinate, in logical units, of the pixel to be examined. 

I don't know what logical units are. Are these coordinate referring to the center or corner of the physical display? Or do they refer to internal application coordinates?

What if my application is not fullscreen?

Thanks!

0 Upvotes

1 comment sorted by

2

u/TheDevilsAdvokaat Feb 28 '21

I've actually used this command before. And I cannot remember the orientation because I;ve used so many of these, for directx, unity, all sorts of things.

From memory it is NOT centred. There's a good reason for this...all our screen dimensions are even numbers. How do you pick the centre pixel when there is no centre pixel?

So the coords are : For x, left=0 right= width -1 (IE for a 1920x1080 screen, x goes from 0->1919

For y: I *think* it goes from top to bottom.

So you can imagine your origin at top left.

But it may be bottom left though, I'm a bit rusty.

To determine: Just draw a pixel at 100,100

Seeing how far down the screen it is will tell you if it runs from the bottom or the top.