I have two different resolutions, the original one is开发者_运维问答 567x756 (wXh), the one which I want to display is 768x1024 (wXh). How to find out the scaling ratio for these two resolutions? For example if the font size used in 567x756 resolution is 7 pts then what's the values I should multiply with the font size (7 pts) to display the text in 768x1024 resolution.
Whenever you hear "scaling", think "proportions":
You can set up a proportion, here:
old width new width
--------- = --------
old font new font
567 768
---- = -----
7 x
567*x = 5376
x = 9.48
So your new font is about 9.48, or 9 if you only want integers.
Alternatively, you could also use the height-to-height proportion in your calculations instead of width-to-width. Or use the average font height you'd get from doing either. Or do old_area/old_font^2 = new_area/new_font^2
If you want a way to find the scaling factor for any arbitrary new width:
old width new width
--------- = --------
old font new font
567 w
---- = ---
7 x
567*x = 7*w
x = (7/567) * w
Given your new w (or h, or w/e), the new font size is (7/567) * w
The aspect ratios are the same for both resolutions, so just take one dimension and use that as your scaling ratio, i.e.
1024/756
Which is about 1.35. Or if you want to scale in the other direction, 0.738
精彩评论