我正在尝试在任何设备上创建一个尺寸为5cm x 8cm的图像。问题是:不同设备具有不同的每英寸点数(dpi),这意味着我需要不同的像素大小来创建图像。如何计算这些不同的像素大小?
我的方法如下:
1.将厘米转换为英寸 float widthInches = 5f / 2.54f; // 1.9685f; float heightInches = 8f / 2.54f; // 3.1496f
2.找到像素大小 float realWidthSize = Screen.dpi * widthInches; float realHeightSize = Screen.dpi * heightInches;
我在我的设备上进行了这些测试,结果并不如预期。我做错了什么吗?
我的方法如下:
1.将厘米转换为英寸 float widthInches = 5f / 2.54f; // 1.9685f; float heightInches = 8f / 2.54f; // 3.1496f
2.找到像素大小 float realWidthSize = Screen.dpi * widthInches; float realHeightSize = Screen.dpi * heightInches;
我在我的设备上进行了这些测试,结果并不如预期。我做错了什么吗?