from:https://blog.csdn.net/qq_29011299/article/details/81137980
using(Bitmap bmp=new Bitmap(300,50))
{
using(Graphics g=Graphics.FromImage(bmp))
{
g.Clear(Color.WhiteSmoke);
g.DrawString("字符串", new Font("隶书", 40), Brushes.Red, new PointF(50, 0));
g.DrawEllipse(new Pen(Color.Green, 2), 10, 10, 10, 10);
}
using(System.IO.MemoryStream ms=new System.IO.MemoryStream())
{
bmp.Save(ms,System.Drawing.Imaging.ImageFormat.Png);
string base64 = Convert.ToBase64String(ms.ToArray());
Image1.ImageUrl = "data:image/png;base64,"+base64;
}
}