Device pixel ratio

Source: Internet
Author: User

Http://www.paintcodeapp.com/news/ultimate-guide-to-iphone-resolutions

What is the detailed calculation method and algorithm source for DPI, PPI, DP, PX? The dpi means dot per inch. That is, the number of points per inch, corresponding to the DP, why do the UI design to use DP and less px? In addition, the PPI calculation method is the resolution of the length and width of the sum of the square divided by the area, how the formula is calculated, the principle is what, do not understand, please advise. Thank you. Add Comment sharingSort by poll by Time6 Answers to users,Dream Bigusers, building Teng,Kelly Hwong and other people agree 1. DPI is the dot per inch, how many dots, PPI is Pixel per inch, pixels per inch, for the design of the display, Dpi=ppi.
The PPI calculation method is the sum of the length and width of each square, divided by the diagonal length (in inches). Principle can draw a rectangle of the Pythagorean theorem to calculate a calculation.
2. PPI indicates the point density of the display device, and DPI indicates the print point density.
3. Dip or DP, which is an Android development unit, 1DP indicates 1px length at a screen point density of 160ppi.
Since the Android device screen is numerous and cannot be developed individually for each screen, the number of pixels on different screens is calculated using the formula px=dp* (ppi/160).
Example: HVGA screen 320*480, generally 3.5 inch, calculate the point density is √ (320^2 + 480^2)/3.5 = 164, approximately equal to 160,1pd=1px
WVGA screen 480*800, press 3.8 inch screen count, point density Yes (480^2 + 800^2)/3.8 = 245, approximately equals 240,1dp=1.5px.
There is a higher resolution of the screen is not listed, in short, DP is to facilitate the adaptation of different screen units, at different screen densities, the physical length of the 1DP is the same.

---------------------------------------------------------------------------
2014-2-28 changes, the above can not understand from here to start to see

The LCD display image, magnification is a small dot, these dots are pixels (px).

Some mobile phone screen small pixel points, such as HTC G11 4-inch 480x800 screen, there are many large pixel screen, such as Samsung NOTE2 5.5-inch 720x1280 screen.

This icon is displayed on different phone screens, which is the effect. Can imagine our different phones open the same application, the size of the buttons vary greatly.

What determines the size of the picture, screen size? The 1th and 2nd screens are all 4.3 inches. Number of pixels? Both the 2nd and 3rd screens are 720x1280 pixels. Finally we find the dot density (density), which is the ratio of the number of pixels to the screen size. Density is the number of pixels per unit length, typically in pixels per inch, or pixel per inch (PPI).

The size of the screen is the length of the diagonal of the screen, counting the number of diagonal pixels and dividing the screen size to get the PPI value. The dot density of the above 3 screens is 217ppi,327ppi (should be 342ppi), 267ppi, respectively.

By contrast, the lower the PPI, the larger the picture, and the higher the PPI, the smaller the picture appears.

To make different screens display the same size, you need to scale the image to provide a larger picture for the high PPI screen.

A high PPI screen requires a larger picture for the same display effect, and vice versa. The relationship between PPI and picture px is as follows

Px1/px2=ppi1/ppi2

Select a PPI value as the basis for drawing pictures, the ratio of PPI to calculate the image scale can be adapted to various screens

Px2=px1* (PPI2/PPI1)

The base value selected by Android is 160ppi

Px2=px1* (ppi2/160)

We have solved the problem of zooming in and out of the image, and we need a unit to describe the length (because PX is not fixed and inch is inconvenient). Android has created a new unit DP, Chinese name device independent pixels. And on the 160ppi screen, 1dp=1px.

Designers only need 160ppi display design and mapping, Android will be based on the current cell phone screen PPI value to zoom in and out of the picture, on different screens to get similar display effect.


------------------------------------------------------------
2014-2-12 revision, Supplementary section on SP unit content

The text unit of the Android device is SP, and the simple understanding and DP are the same.

The following paragraph was copied from Android design:

You can create an orderly, easy-to-understand layout using different size font comparisons. However, in the same user interface there are too many

Different sizes of fonts, will be very messy. The Android framework uses the following sizes:

Corresponding to the app:

Above this one (simple processing), the red letter marked the corresponding text type.

The actual use is not so absolute. Chinese app, medium 16SP text too large, the body is also commonly used in small 14SP. The super small 12SP is not small enough, for example, to use a smaller font size.

PS design, for the corresponding standard (HDPI,XHDPI,XXHDPI), the use of different px.

Device pixel ratio

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.