如何根据计算机的DPI转换像素测量值 [英] how can I convert pixel measurement according to computer's DPI

查看:164
本文介绍了如何根据计算机的DPI转换像素测量值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





我已经向几个用户发布了我的wpf项目。

在我的项目中 - 用户可以放置鼠标在画布上,我在数据库中保存了像素(x,y)的确切点。



我注意到用户通过他保存了几个点后计算机(设置为113DPI),当我试图看到他的点在一个完全不同的地方(我的电脑设置为96DPI,这是我所知道的标准)。



你可以建议一种方法,一个计算来改变他保存的所有点,以便它适合其余的计算机吗?



例如

名称 position_X position_Y

point_001 2505 1749



我希望你明白我的意思。



thanx。

Hi,

I've published my wpf project to several users.
In my project - a user can place the mouse on a canvas and I save the exact point in pixels(x, y) in my database.

I've noticed that after a user that saved several points through his computer (which set to 113DPI), when I tried to see his points it were in a completely different places (my computer is set to 96DPI which is the standard as far a I know).

can you suggest a way, a calculation to change all the points he saved so it will fit the rest of the computers?

for example
name position_X position_Y
point_001 2505 1749

I hope that you'll understand what I mean.

thanx.

推荐答案

公式很简单:

The formula is simple:
target_x = source_x * target_dpi / source_dpi;
..


这篇关于如何根据计算机的DPI转换像素测量值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆