Flex / actionscript - DPI screen

Is there a way to get an image on the screen?


I tried Capabilities.screenDPI, but it is broken, it always returns 72.


Any ideas?

Thank you very much.

+4
source share
2 answers

I could never completely wrap my head around why this is so, but it is really correct. If you want information on width in height, you can use Capabilities.screenX and Capabilities.screenY .

I believe you should use a Mac. 72 is often a dpi resolution on Mac computers; on a Win machine, the value is usually 96.

The following quote helped me a lot. This is from a long message about dpi and screen resolution at http://www.scantips.com/no72dpi.html . The message is only related to your question, but information on how the screen works works.

Your web browser reports that the screen size is currently set to 1440x900 pixels (the total area of โ€‹โ€‹your screen, not just the browser window). Therefore, each image with a size of 412x324 pixels will be displayed in the format 412/1440 = 29% and 324/900 = 36% of the height of your full-screen mode (at the current video settings). I can easily promise that this is true even without being there, but you can check it on your screen for yourself. I hope this seems obvious to you too, because that's how video systems work, and you need to know that.

UPDATED:

After a few more studies -

As you know, the screenDPI property screenDPI not give you the actual number of pixels per inch - you will get the same value for screenDPI on 800x600 as on 1440x900. If you already know the screen size in inches, then you can calculate the actual ppi - but, of course, you cannot get this information from ActionScript. In IE, you can get it from JavaScript, but that doesn't help much.

So, there is no way to do this, as far as I can tell. Perhaps you could do something like crazy, for example, click a screenshot of your application with AS and send it to the server with information about the screen resolution, and let the server analyze it, telling how many inches in width and height you use - and so As you know how many pixels wide and tall your application is, you can calculate pixels per inch. But I have no idea how to do this if the server application does this.

I was hoping there might be a way to get this through JavaScript. I saw a couple of messages about setting div width / height to 1in and then request offsetWidth / offsetHeight, but this does not work better than screenDPI . Interestingly, I get 96 from this method (regardless of resolution), although I get 72 from screenDPI .

As far as I can tell, there is no way to determine the actual pixels in an inch without anticipating the screen size in inches - and you cannot get this information from the browser.

Bummer.

+2
source

Suppose you have 2 monitors, 17 "and 19" with a SAME resolution of 1280x1024 (I have exactly these two). this means that the actual DPI, which reflects the pixel size (or exactly the number of pixels that correspond to one inch), will be DIFFERENT for these two smaller monitors with the same resolution, will have a larger DPI value.

this means that there is no way to get the actual DPI from actioncript or javascript. you can get the screen width (1280) in pixels, but you cannot get the actual monitor size in inches, so you cannot calculate it.

Suppose windows returns a default value of 72 and mac 96, but this, unfortunately, does not reflect the real value.

this means that there is no way, for example, to make a square 10 inches wide on all monitors: \

on Windows, if you installed the monitor drivers correctly, maybe you can get DPI from the monitor driver (I suppose 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.

+1
source

All Articles