Share via

Coordinates based on resolution, scaling, etc.?

Anonymous
2022-06-10T21:16:48+00:00

Hello,
my question is kind of similar to this in a way:

https://answers.microsoft.com/en-us/windows/forum/all/regarding-the-object-position-across-different/ab638147-e2c0-41b0-9c61-6e8bd2ac7976
what
 my problem is:
I program in java and use the "robot" class there to get color info on a certain pixel or click stuff on a given coordinate.
anyways, all stuff there is based on a given cooordinate.

so I wrote my program and the used coordinates were measured (with said Robots .getPixel(x,y) method) depending on the currently chosen resolution of 1920 x 1080 and text scaling of 125%.

anyways, when using said robot class, the pixel positions go from (0,0) (left top corner) to (1535, 861) (bottom right corner).
so "virtual" dimensions of 1536 x 862

so the "initial" length and height of 1920 x 1080 are taken and divided by 125%=1.25, aka the scaling factor.

so far, so good.

however now I wanna use that very same program in a virtual machine, namely virtual box and use windows 10 there as well.

To make things as close to before as possible, I'll also use 125% scaling and try to make basically everything the same.
sadly, for obvious reasons I cant make the resolution to 1920 x 1080 as well
but can only chose the next smallest resolution (1640 x.. or such).

Now I have come to wonder, given a coordinate measured in the previous setup, how can I calculate its new coordinate?
I would asusme that it goes simply via
xnew=xold*newscreenlength/oldscreenlength , in this case xnew=xold*1640/1920

similar thing for the y coordinate.

but thgats jsut a wild guess from me.

I dont know, if when changing resolutions, windows really scalles things as if coordinates were jsut vectors from top left to the wante dpoint and they jsut get strechted or scaled according to the x and y stretching.

or if the behaviour doesnt change that linear at all.

so has anyone confirmed knowledge how these "virtual" coordinates are transformed when switching reolutions, is it really jsut a simple linear stretching or how does it work?

Windows for home | Windows 10 | Settings

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

1 answer

Sort by: Most helpful
  1. Anonymous
    2022-06-11T12:32:56+00:00

    Hi Bernd_261,

    Welcome to post in Microsoft Community.

    According to your description, it seems to be a problem with the determination of position coordinates in Java programming.

    Sorry, this forum is mainly aimed at individual users of Microsoft products, providing them with basic solutions to problems encountered in daily use. For professional questions, recommend you go to **** Microsoft Docs(microsoft.com) for help. This community caters to IT professionals who can provide advanced troubleshooting steps for your concern. You can click Q&A to post your question.

    Hope your problem can be solved soon!

    Best Regards,

    Mosken- MSFT | Microsoft Community Support Specialist

    Was this answer helpful?

    0 comments No comments