28-5-2018 13:51:51
string captcha = CommonFunction.GetGuid().Substring(0, 4).ToUpper();
Session["CAPTCHA"] = captcha;
int wid = 180;
int hei = 40;
string fname = UrlProvider.RootFolder + "/images/captcha.jpg";
string file = Server.MapPath(fname);
System.Drawing.Image img = System.Drawing.Image.FromFile(file);
Bitmap bmp = new Bitmap(wid, hei);
Graphics gr = Graphics.FromImage(bmp);
System.Drawing.RectangleF rec = new RectangleF(0, 0, wid, hei);
gr.DrawImage(img, rec);
Font font = new Font("Arial", 18, System.Drawing.FontStyle.Bold);
PointF pointf = new PointF(16, 6);
Brush brush = GetBrush();
gr.DrawString(captcha, font, brush, pointf);
font = new Font("Arial", 10);
Response.ContentType = "image/jpeg";
Response.Clear();
bmp.Save(Response.OutputStream, System.Drawing.Imaging.ImageFormat.Jpeg);
bmp.Dispose();
Response.Flush();
Response.End();
---
Cây sẽ cho lộc và cây sẽ cho hoa ...