private void GetstringImg(string outstring, int with, int height, Color color)
{
Bitmap imgage = new Bitmap(with,height);
Graphics g = Graphics.FromImage(imgage);
Font font = new Font("宋体",12, FontStyle.Bold);
SolidBrush brush = new SolidBrush(color);
g.Clear(Color.White);
StringFormat format = new StringFormat();
g.DrawString(outstring, font, brush, 0,0,format);
MemoryStream ms = new MemoryStream();
imgage.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg);
content.Response.ClearContent();
content.Response.ContentType = "image/pjpeg";
content.Response.BinaryWrite(ms.ToArray());
}
调用:
GetstringImg("189.00",30,10,Color.Red);