Two Generate Text as Image
[HttpPost]
public ActionResult NewImg(string txt)
{
FileContentResult img = null;
using (var mem = new MemoryStream())
using (var bmp = new Bitmap(130, 30))
using (var gfx = Graphics.FromImage((Image)bmp))
{
gfx.TextRenderingHint = TextRenderingHint.ClearTypeGridFit;
gfx.SmoothingMode = SmoothingMode.AntiAlias;
gfx.FillRectangle(Brushes.White, new Rectangle(0, 0, bmp.Width, bmp.Height));
gfx.DrawString(txt, new Font("Tahoma", 15), Brushes.Gray, 2, 3);
bmp.Save(mem, System.Drawing.Imaging.ImageFormat.Jpeg);
img = this.File(mem.GetBuffer(), "image/Jpeg");
}
return img;
}
View
<h2>NewImg</h2>
@using(Html.BeginForm()){
@Html.Label("Text")
@Html.TextBox("txt")
<input type="submit" value="new image" />
}