View Full Version : identify ppi/dpi of mobile devices

2 Jan 2012, 5:31 AM
Is there a way to identify the pinch-per-pixel of mobile devices?

The following example

var t = Ext.getBody().createChild({style:{width:'2.54cm'}},null,true);
dpi = t.offsetWidth;
allways gives me a value of 96 which seems to be a typical desktop-resolution.

2 Jan 2012, 6:14 AM
If you are trying to create display independent UIs, the use of em and then line-height is very useful.

2 Jan 2012, 6:52 AM
I need it for map scale so that e.g. 1 inch on a display of a mobile device equates 1 mile in the real world.

My app communicates with a map service that works with width/height, a bounding box and pixel density.

2 Jan 2012, 6:57 AM
Is it known the dimensions of the map when it is rendered? So say the map renders at 200px wide and 400px tall and the map is 1 mile wide by 2 miles tall

2 Jan 2012, 7:14 AM
The map service adjusts the given bounding-box (world coordinates) to the preferred resolution and pixel density so the resulting image will be different when changing pixel density.

So is it impossible to identify/evaluate the ppi from the device?