asp.net/C#形成点阵字体的图片
来源:百度知道 编辑:UC知道 时间:2024/05/23 18:06:04
点阵字体默认是宋体,有两种大小:16*16或是24*24点阵。
知道的大哥给点思路指导下。
东西要在ASP.NET下实现的。
using System.Drawing;
checkcode是存放字符串的
int iwidth = (int)(checkCode.Length * 11.5);
System.Drawing.Bitmap image = new System.Drawing.Bitmap(iwidth, 20);
Graphics g = Graphics.FromImage(image);
Font f = new System.Drawing.Font("Arial", 10, System.Drawing.FontStyle.Bold);
Brush b = new System.Drawing.SolidBrush(Color.Blue);
g.Clear(Color.Snow);
g.DrawString(checkCode, f, b, 3, 3);
System.IO.MemoryStream ms = new System.IO.MemoryStream();
image.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg);
Response.ClearContent();
Response.ContentType = "image/Jpeg";
Response.BinaryWrite(ms.ToArray());
g.Dispose();
image.Dispose();
GDI+