Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to detect DPI in iPhone OS, or Android?

I'm doing some research on making a game that will be able to scale its graphical resources to suit the DPI of whatever device it's on.

In order to do this, I would like to be able to query the DPI of the device, to appropriately scale the assets.

It's a 2D game, and the art style suits arbitrary scaling quite well.

example of what I would do with res/dpi combos:

iPhone/iTouch, at 320x480 (163 dpi) - text will be the normal size

iPhone4, at 640x960 (326 dpi) - text will be twice as large

iPad, at 768x1024 (132 dpi) - text will probably be capped at some minimum size, to take advantage of the greater screen real estate.

So, on iPhone OS, is there a way to query the screen's DPI?

(and as a side note - is this possible on Android devices at all?)

like image 381
Jakooistra Avatar asked Nov 06 '22 11:11

Jakooistra


1 Answers

You can fetch this information in Android with the DisplayMetrics class.

like image 107
iandisme Avatar answered Nov 12 '22 15:11

iandisme