admin管理员组文章数量:1346203
Question says it all really. I want to be able to display something at actual size, so, for example, if something is displayed in the browser as 20cm, I want to be able to measure it and it to actually be 20cm.
So far I have e across solutions which take into account the diagonal resolution of the screen (such as 21.5 inches) and the screen resolution to calculate how big a pixel is.
Another approach is to ask the user to put up a standard sized card such as a bank card to the screen and measure the edges to calculate the size.
Is there a way to do this without a physical object on the screen or without the user needing to know their diagonal screen size?
Please also let me know if you know of any different solutions other than the ones I have mentioned.
Question says it all really. I want to be able to display something at actual size, so, for example, if something is displayed in the browser as 20cm, I want to be able to measure it and it to actually be 20cm.
So far I have e across solutions which take into account the diagonal resolution of the screen (such as 21.5 inches) and the screen resolution to calculate how big a pixel is.
Another approach is to ask the user to put up a standard sized card such as a bank card to the screen and measure the edges to calculate the size.
Is there a way to do this without a physical object on the screen or without the user needing to know their diagonal screen size?
Please also let me know if you know of any different solutions other than the ones I have mentioned.
Share Improve this question asked Jul 26, 2011 at 13:55 betamaxbetamax 14.1k9 gold badges42 silver badges55 bronze badges 1- 1 Also don't forget that device pixel != pixel, stackoverflow./questions/4366148/… (In this case it may work for you, as the lie about the physical size of a pixel in iOS unify the retina an non retina displays) BTW physical size also depends on zoom level :-) – Julien Roncaglia Commented Jul 26, 2011 at 14:25
2 Answers
Reset to default 9You can't do this with absolute certainty, no. For example, if the display device is not a screen, but a video projector, the effective size will depend on the distance of the projector to the wall, which can change without the operation system getting any feedback.
Most operation systems have some dpi setting (dots per inch), which might either be configured by the user or system administrator, hard-coded (if the video device is build in and can't be changed, like a laptop screen), or maybe automatically discovered (if the video protocol supports this).
Either this setting or a similar browser setting will be used by the browser to calculate absolute sizes used in CSS, like cm
, mm
, in
, pt
, and so on.
So you could simply rely on the browser to show it right, or tell your user to set the setting right. (Of course, on a video projector with projection size 3×4 m you don't really want to show a 20 cm object.)
It had been suggested in other places that making a hidden 1" div and then querying the pixel width would get a virtual DPI that you could use to calculate the size by getting the screen width and height in "pixels". I haven't tried this myself yet.
本文标签:
版权声明:本文标题:javascript - Is it possible to get a users physical screen size without the use of a physical object or the diagonal measurement 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1743822119a2544976.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论