Example #1
0
 protected override void OnPreInit(EventArgs e)
 {
     Response.Clear();
     var captcha = new SimpleCaptcha();
     captcha.SessionName = CaptchaSessionName;
     captcha.WordsFile = "~/App_Data/words-en.txt";
     using (var image = captcha.CreateImage())
     {
         Response.ContentType = "image/png";
         image.Save(Response.OutputStream, ImageFormat.Png);
         Response.End();
     }
 }
Example #2
0
 public static void GenerateAll()
 {
     var foldeName = String.Format("{0:yyyyMMddHHmmss}", DateTime.Now);
     var captcha = new SimpleCaptcha();
     captcha.MinWordLength = 6;
     captcha.MaxWordLength = 6;
     captcha.Scale = 6;
     for (int i = 0; i < 8; i++)
     {
         for (int j = 0; j < 10; j++)
         {
             captcha.FontConfig = SimpleCaptcha.Fonts[i];
             using (var image = captcha.CreateImage())
             {
                 var path = String.Format("{0}{1}\\{2}-{3}.png", AppDomain.CurrentDomain.BaseDirectory, foldeName, i, j);
                 Directory.CreateDirectory(Path.GetDirectoryName(path));
                 image.Save(path, ImageFormat.Png);
             }
         }
     }
 }