Alex Brown

Alex Brown

  • NA
  • 10
  • 0

Text on image - watermark - font size

May 22 2008 5:07 PM
I have images, that are stored in sql server.
 
One of the images is retrieved, into a memory stream, then returned as an Image object.
 
I then have a method called addWatermark(string text, Image img)
 
Graphics g = Graphics.FromImage(image);
g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
g.DrawString(text, new Font("Tahoma",fontSize), Brushes.White, new PointF(0, 0));
 
i want the text to take up around 70% of the width of the image... im trying to calculate the value fontSize
 
the image thats passed in could be any size.... not always the same size.
 
Basically, i need to calculate the max font size, then reduce it by 30% i guess.
 
any ideas?

Answers (2)