更新时间:2023-02-11 11:06:13
这全部取决于屏幕截图的大小和当前分辨率的大小.
It all depends on the size of the screenshot and the size of your current resolution.
假设屏幕截图为800x600,但您当前的屏幕分辨率为1280x720.为了找出800x600图像上的X,Y位置,您需要对1280x720屏幕上X,Y的值进行标准化.
Let's say the screenshot is 800x600, but your current screen resolution is 1280x720. In order to find out the X,Y position on a 800x600 image, you need to normalize the values you have of X,Y on a 1280x720 screen.
normalized_x = (x * 800) / 1280;
normalized_y = (y * 600) / 720;
请注意,在800x600图像上,您要查找的对象也较小.所以:
Note that the object you are looking for is also smaller on a 800x600 image. So:
// w and h represents the size of the object at 1280x720
normalized_w = (w * 800) / 1280;
normalized_w = (h * 600) / 720;