iOS scale conversion 1mm equals how many pixels understand

Source: Internet
Author: User

Tag: Is the IMG demo conversion sqrt a wide high height post

Just see a scale article, realize the mobile phone screen painting scale.

Then there is a question: how does the actual 1mm (1 mm) length compare to cell phone pixels?

Looked at the demo code, found this write:

CGFloat Sc_w =[[UIScreen mainscreen] bounds].size.width; CGFloat Sc_h=[[UIScreen mainscreen] bounds].size.height;    CGFloat sc_s; CGFloat FF=[[UIScreen mainscreen] nativebounds].size.height; if(ff = =1136) {sc_s=4.0; }Else if(ff = =1334.0) {sc_s=4.7; }Else if(ff==1920x1080) {sc_s=5.5; }Else if(ff==2436) {sc_s=5.8; }Else{sc_s=3.5; }        //1mm m Pixel pointPMM = sqrt (sc_w * sc_w + sc_h * sc_h)/(sc_s *25.4);//mm

The above PMM is obtained 1mm = PMM pixels

What's the solution?

The original is this:

1, according to cell phone pixel value: [UIScreen mainscreen] nativebounds, get phone size in inches (4, 4.7, 5.5, etc.)

2, according to the width of the mobile phone, according to the Triangle Hook stock Law, calculate the hypotenuse length xiebian= sqrt (sc_w * sc_w + sc_h * sc_h)

3, the focus is this 25.4, has not understood this number, and finally found that because: 1 inches = 2.54 centimeters, that is, 25.4mm, you can get a hypotenuse corresponding to the millimeter value: (sc_s * 25.4)

4, then is used to get the hypotenuse length pixel/millimeter value, to get 1mm corresponding pixel value

5, finally, according to this value slowly draw the scale ~

soga~

iOS scale conversion 1mm equals how many pixels understand

Related Article

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.