Search code examples
c#.netdrawingimage-manipulation

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


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?


Solution

  • Use Graphics.MeasureString() to compute the width.