把文本框的值转换成一个Image,很一个很简单的,主要用到的.NET类库是:
System.Drawing;
很简单的,先看代码吧:
protected void btnConvert_Click(object sender, EventArgs e)
{
System.Drawing.Bitmap b = new System.Drawing.Bitmap(150, 80, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
System.Drawing.Graphics g = System.Drawing.Graphics.FromImage(b);
string a = txtValue.Text.ToString();
g.Clear(System.Drawing.Color.Blue);
g.DrawString(a, new Font("Arial", 18, FontStyle.Bold), new SolidBrush(Color.BurlyWood), new PointF(05.0f, 1.50f));
Response.ContentType="image/jpeg";
b.Save(Response.OutputStream, System.Drawing.Imaging.ImageFormat.Jpeg);
}
{
System.Drawing.Bitmap b = new System.Drawing.Bitmap(150, 80, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
System.Drawing.Graphics g = System.Drawing.Graphics.FromImage(b);
string a = txtValue.Text.ToString();
g.Clear(System.Drawing.Color.Blue);
g.DrawString(a, new Font("Arial", 18, FontStyle.Bold), new SolidBrush(Color.BurlyWood), new PointF(05.0f, 1.50f));
Response.ContentType="image/jpeg";
b.Save(Response.OutputStream, System.Drawing.Imaging.ImageFormat.Jpeg);
}
就是把文本框中的值画成一个IMAGE最后在页面上显示OK
效果: