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