Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I convert to DIP?

What is the formula for converting regular pixels to DIP?

Assuming I have a photoshop document with a design in it that was intended for the Galaxy Tab (for example) which is 600x1024 actual pixels.
What is the ratio between those and the DIP? I'm unclear on how Android translates this.

I want to use DIP (rather than pixels) so that it scales to look "ok" on other devices, but my primary concern is to get it pixel perfect in this resolution and my aim is to measure the position of an element in photoshop and then get an exact translation as to what the DIP needs to be for it to lay out identically on the Tab.

like image 342
Yevgeny Simkin Avatar asked Jun 07 '11 17:06

Yevgeny Simkin


People also ask

How do you convert a strike to a dip?

How do you calculate dip directions from a strike? The dip direction is Always 90 degrees from the strike direction.

What size is 300 DPI in KB?

So a 10mm image is 118 px square at 300 dpi making 109 kb multiplying that by 10, the 100mm image is 1181 px square. Using these dimensions you should be able to multiply up to the rough size you will need for either 300 or 72 dpi.

What size is 200 DPI in KB?

Below is a theoretical overview on how to calculate the file sizes. Compression ratios (approx.) So assuming ideal conditions we should be able to get an A4 page scanned at 200 dpi, B&W in to a 25 Kb TIFF file.


1 Answers

Their formula is somewhere in the docs:

 truePixels = DIPs * (device DPI / 160) 

Ah, there it is:

The density-independent pixel is equivalent to one physical pixel on a 160 dpi screen, which is the baseline density assumed by the system for a "medium" density screen. At runtime, the system transparently handles any scaling of the dp units, as necessary, based on the actual density of the screen in use. The conversion of dp units to screen pixels is simple: px = dp * (dpi / 160). For example, on a 240 dpi screen, 1 dp equals 1.5 physical pixels. You should always use dp units when defining your application's UI, to ensure proper display of your UI on screens with different densities.

Taken from here.

like image 67
dmon Avatar answered Oct 03 '22 17:10

dmon