标签:style blog http color os io for ar
很简单的代码,记录下,防止忘记。
实现过程和生成验证码相似
public void SavePhoneImg(string Phone, string path) { System.Drawing.Bitmap image = new System.Drawing.Bitmap(135, 25); Graphics g = Graphics.FromImage(image); try { Font font = new System.Drawing.Font("楷体", 15, (System.Drawing.FontStyle.Bold)); System.Drawing.Drawing2D.LinearGradientBrush brush = new System.Drawing.Drawing2D.LinearGradientBrush(new Rectangle(5, 5, image.Width, image.Height), Color.Black, Color.Black, 1.2f, true); g.DrawString(Phone, font, brush, 2, 0); //画图片的边框线 g.DrawRectangle(new Pen(Color.Silver), 0, 0, image.Width - 1, image.Height - 1); System.IO.FileStream ms = new System.IO.FileStream(path, FileMode.Create); image.Save(ms, System.Drawing.Imaging.ImageFormat.Png); } finally { g.Dispose(); image.Dispose(); } }
根据传入的文字生成图片 并保存,布布扣,bubuko.com
标签:style blog http color os io for ar
原文地址:http://www.cnblogs.com/bobo-pcb/p/3924694.html