Carrotware.Web.UI.Controls.CarrotHttpHandler.DoCaptcha C# (CSharp) Метод

DoCaptcha() приватный Метод

private DoCaptcha ( HttpContext context ) : void
context System.Web.HttpContext
Результат void
        private void DoCaptcha(HttpContext context)
        {
            Color f = ColorTranslator.FromHtml(CaptchaImage.FGColorDef);
            Color b = ColorTranslator.FromHtml(CaptchaImage.BGColorDef);
            Color n = ColorTranslator.FromHtml(CaptchaImage.NColorDef);

            Bitmap captchaImg = CaptchaImage.GetCaptchaImage(f, b, n);

            if (captchaImg == null) {
                context.Response.StatusCode = 404;
                context.Response.StatusDescription = "Not Found";
                context.ApplicationInstance.CompleteRequest();
                return;
            }

            context.Response.ContentType = "image/x-png";

            using (MemoryStream memStream = new MemoryStream()) {
                captchaImg.Save(memStream, ImageFormat.Png);
                memStream.WriteTo(context.Response.OutputStream);
            }
            context.Response.StatusCode = 200;
            context.Response.StatusDescription = "OK";
            context.ApplicationInstance.CompleteRequest();

            captchaImg.Dispose();
            context.Response.End();
        }