Windows DPI设置会影响Graphics.DrawString [英] Windows DPI setting affects Graphics.DrawString

查看:132
本文介绍了Windows DPI设置会影响Graphics.DrawString的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个新的Bitmap对象,现在想使用GDI +向其绘制一些文本. 所以我叫Graphics.DrawString(...).

I have created a new Bitmap object and now want do draw some text to it using GDI+. So I call Graphics.DrawString(...).

问题在于字符串的大小取决于Windows 7的DPI设置. 有什么方法可以使我的文本绘图独立于Windows设置吗?

The problem is that the size of the string depends on Windows 7's DPI settings. Is there any way to make my text drawing independent of the windows settings?

PS:DPI设置似乎仅影响文本.例如,在更改DPI时,一个rect样式的大小相同.

PS: The DPI settings seem to affect text only. A rect for example stys the same size when changing the DPI...

推荐答案

我自己找到了解决方案: 关键是使用参数GraphicsUnit.Pixel创建字体.这样,绘制字符串就独立于系统的DPI设置.

Just found the solution myself: The key is to create the font with the parameter GraphicsUnit.Pixel. That way drawing strings gets independent from the system's DPI settings.

这篇关于Windows DPI设置会影响Graphics.DrawString的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆