protected void gethua()
{
//string strbody = "<table width='100' height='100' border='1' cellpadding='0' cellspacing='0' bordercolor='#000000' bgcolor='#FF0000'><tr><td> </td></tr></table>";
Random random = new Random();
Bitmap bt = new Bitmap(400, 600, PixelFormat.Format24bppRgb);
Graphics g = Graphics.FromImage(bt);
Font fn1 = new Font("Tahoma", 20, FontStyle.Bold);
Font fn = new Font("Tahoma", 12, FontStyle.Bold);
//g.Clear(Color.RoyalBlue);
g.Clear(Color.FromName("#FAF5F5"));
g.DrawString("准 考 证", fn1, Brushes.White, new PointF(150, 50));
//g.DrawString(strbody, fn, Brushes.White, new PointF(10, 10));
g.DrawString("年龄:33", fn, Brushes.White, new PointF(50, 90));
g.DrawString("身份证:123456789", fn, Brushes.White, new PointF(50, 130));
g.DrawString("性别:男", fn, Brushes.White, new PointF(50, 170));
for (int i = 0; i < 1000; i++)
{
int x1 = random.Next(400);
//int x2 = random.Next(400);
int y1 = random.Next(600);
//int y2 = random.Next(600);
//g.DrawLine(new Pen(Color.GreenYellow), x1, y1, x2, y2);
bt.SetPixel(x1, y1, Color.FromArgb(random.Next()));
}
g.DrawLine(new Pen(Color.GreenYellow), 30, 30, 30, 200);
g.DrawRectangle(new Pen(Color.CornflowerBlue), 20, 20, 360, 560);
Response.ContentType = "image/Jpeg";
bt.Save(Response.OutputStream, ImageFormat.Jpeg);
}
不显示表格 我可以画
但是图片显示不出来 我实在是无语