The accurate conversion of pixel and dimension by actual resolution and logical resolution

Source: Internet
Author: User

Instance

Recently made a visual inspection of the app project, which used to convert the pixel to the actual size, after the research learned some knowledge, here and you share.

The implementation steps are:

  First get the physical parameters:

1. Cell phone pixel density (1 inches =x pixels) Dpix/dpiy

2. Ratio of actual pixel to logical pixel scale

then figure out how many pixels per millimeter (in our custom use millimeters or centimeters, so convert inches to millimeters, 1 inches = 25.4 millimeters)

Finally convert the virtual pixel to the actual pixel

"Actual resolution vs. Logical Resolution"

As we all know, the computer can be set to a variety of resolutions, can be different from the real pixel, so that will produce a real size and display size ratio, when the same ratio is set at 1, when not the same ratio is not 1, so if you want to get real resolution and size conversion must take advantage of this scale. For example, the actual pixel on the iphone5 is 640*1136, the logical resolution is 320*568, and the ratio is 2.

The conversion formula is: true resolution = logical Resolution X scale

The accurate conversion of pixel and dimension by actual resolution and logical resolution

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.