我不能把验证码写入图片中。。怎么办!
using System;using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Drawing;
using System.Drawing.Imaging;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
string str = suiji(4);
Bitmap bit = new Bitmap(50, 20);
Graphics g = Graphics.FromImage(bit);
Font text = new Font("宋体",20);
Rectangle rec = new Rectangle(0,0,50,20);
g.FillRectangle(new SolidBrush(Color.Green), rec);
g.DrawString(str, text, new SolidBrush(Color.Blue),rec);
bit.Save("yanzhen.jpg",ImageFormat.Jpeg);
Image1.ImageUrl = "yanzhen.jpg";
}
public string suiji(int a)
{
string result = "";
string str = "0,1,2,3,4,5,6,7,8,9";
string[] arry = str.Split(',');
Random ram = new Random();
for (int i = 0; i < a; i++)
{
int k = ram.Next(10);
result = result + arry[k];
}
return result;
}
}
不能显示!