问题
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 this?
回答1:
Use Graphics.MeasureString() to compute the width.
回答2:
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
来源:https://stackoverflow.com/questions/2555739/how-to-measure-the-pixel-width-of-the-string-drawed-over-drawing-bitmap-in-net