Hi,
Is there a way to get the screen dpi ?
I have tried Capabilities.screenDPI but it is broken, it always return 72.
Any Ideas?
Many Thanks.
Hi,
Is there a way to get the screen dpi ?
I have tried Capabilities.screenDPI but it is broken, it always return 72.
Any Ideas?
Many Thanks.
Hi. I've never been able to completely wrap my head around why this is, but that is actually correct. If you want to get width by height information, you can use Capabilities.screenX
and Capabilities.screenY
.
I believe you must be using a Mac. 72 is often the dpi on Macs; on a Win machine, the value will usually be 96.
The following quote helped me a lot. It's from a long post about dpi and screen resolution at http://www.scantips.com/no72dpi.html. The post is only tangentially related to your question, but the information on how screen dpi works is helpful.
Your web browser reports that your screen size is currently set to show 1440x900 pixels (the overall full area of your screen, not just the browser window). Therefore each 412x324 pixel image above will appear at 412/1440 = 29% width and 324/900 = 36% height of your full screen (at your current video setting). I can easily promise this is true without even being there, but you can check it on your screen for yourself. I hope this seems obvious to you too, because it is how video systems work, and you need to know that.
UPDATED:
After some more research --
As you know, the screenDPI
property doesn't give you the actual number of pixels per inch - you'll get the same value for screenDPI
at 800x600 as you will at 1440x900. If you already know the dimensions of the screen in inches, then you can calculate the actual ppi - but, of course, you can't get that info from ActionScript. In IE, you can get it from JavaScript, but that doesn't help much.
So, there's no way to do this, as far as I can tell. Possibly, you could do something kind of crazy like snap a screenshot of your application with AS, and send it to the server with screen resolution information, and let the server analyze it tell you how many inches wide and tall you r app is - and since you know how many pixels wide and tall your app is, you could then calculate pixels per inch. But, I have no idea how or if a server app would accomplish that.
Was hoping there might be a way to get this via JavaScript. I've seen a couple of posts about setting a div's width/height to 1in and then querying the offsetWidth/offsetHeight, but that doesn't work any better than screenDPI
. Interestingly, I get 96 from this method (regardless of resolution), even though I get 72 from screenDPI
.
As far as I can tell, there is no way of determining the actual pixels in an inch without foreknowledge of the screen's dimensions in inches - and you can't get that information from the browser.
Bummer.
It such a shame there is no automatic way of doing this.
Thanks rhtx for all your research and time.
suppose you have 2 monitors, 17" and 19" with SAME resolution 1280x1024 (i have exactly those two). that means that actual DPI, that reflects pixel size (or precisely, number of pixels that fit in one inch) will be DIFFERENT for those two - smaller monitor with same resolution will have larger DPI value.
it means that there is no way to get actual DPI from actionscript, or javascript. you can maybe get screen width (1280) in pixels, but you cannot get actual monitor size in inches, so you cannot calcualate it.
i suppose that windows returns default value of 72 and mac 96, but that unfortunately does not reflect real value.
that means that there is no way to, for example, make a square that will be 10 inches wide on all monitors :\
in windows, if you have installed your monitor drivers correctly, maybe you can get DPI from the monitor driver (i suppose that's the thing you can get from ie) but it seems to me that there is no way to make it work on all browsers / platforms.