开发者

How to measure the pixel width of the string drawed over Drawing.Bitmap in .NET?

开发者 https://www.devze.com 2022-12-25 01:54 出处:网络
I am generating a .png image that contains a text dynamically written. I need to create the bitmap with the minimum width for file size reasons.

I am generating a .png image that contains a text dynamically written.

I need to create the bitmap with the minimum width for file size reasons.

How do I do t开发者_开发百科his?


Use Graphics.MeasureString() to compute the width.


You can also use TextRenderer for slightly more accuracy. See this article for differences between this and Graphics.MeasureString :

http://msdn.microsoft.com/en-us/magazine/cc751527.aspx

0

精彩评论

暂无评论...
验证码 换一张
取 消