转换像素点 [英] Convert Pixels to Points
问题描述
我有需要的像素转换为点在C#。我见过的话题有些复杂的解释,但似乎无法找到一个简单的公式。让我们假设一个标准96DPI,我怎么calulate这种转换?
I have a need to convert Pixels to Points in C#. I've seen some complicated explanations about the topic, but can't seem to locate a simple formula. Let's assume a standard 96dpi, how do I calulate this conversion?
推荐答案
有每英寸 72分>;如果它是足够的假设每英寸96个像素,该公式是相当简单:
There are 72 points per inch; if it is sufficient to assume 96 pixels per inch, the formula is rather simple:
分=像素*九十六分之七十二
points = pixels * 72 / 96
有办法让每个显示器的寸配置的像素,但它脱离了我的时刻。
There is a way to get the configured pixels per inch of your display, but it escapes me at the moment.
编辑:我在想的功能是GetDeviceCaps。微软有一个名为发展DPI的应用程序指导,查找节创建DPI -Aware字体。
The function I was thinking of is GetDeviceCaps. Microsoft has a guide called "Developing DPI-Aware Applications", look for the section "Creating DPI-Aware Fonts".
这篇关于转换像素点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!