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
精彩评论