Archive |
News - |
By ale73 at 2012-02-15 To provide a captcha system I have created the following step
using System.Drawing and System.Drawing.Image here is the code in Page looa of Default.aspx.cs protected void Page_Load(object sender, EventArgs e) { Response.ContentType = "image/png"; Random r= new Random(); int numr = r.Next(100000); Bitmap img = new Bitmap(400, 100); Graphics g = Graphics.FromImage(img); g.FillRectangle(Brushes.Blue, 0, 0, 400, 200); Font f = new Font("Arial", 30); g.DrawString(Convert.ToString(numr), f, Brushes.White, 120, 20); Pen p = new Pen(Color.Yellow, 2); Random rp = new Random(); Random r2 = new Random(); int n = r2.Next(0, 5); for (int i = 0; i <= n; i++) { int nrp = rp.Next(0, 100); g.DrawLine(p, 0, nrp, 400, nrp); } int numpunti = r2.Next(0, 500); System.Drawing.Image imgp = System.Drawing.Image.FromFile(Server.MapPath("puntorosso2.png")); for (int j = 0; j < numpunti; j++) { int x1 = rp.Next(0, 400); int y1 = rp.Next(0, 100); g.DrawImage(imgp, x1, y1); } img.Save(Response.OutputStream, ImageFormat.Png); g.Dispose(); img.Dispose(); imgp.Dispose(); Response.End(); } if you want iclude in your page, you can do this by here is the code to download captcha.rar |
Login or Register |
Information of Blog |
Home |
Welcome all!! |
Last Posts |
Categories | |
classic ASP (2) | |
DotNET (3) |