I created a 6 digit alphanumeric text in C # and now I need to display it as an image. For this I use Bitmap
and Graphics
in .Net.
As a result of this, I can get the image, but I need small changes in the font of the image, as we see in the Captcha Challenge zigzag, to make it a little difficult to read.
Here is my code ...
Bitmap bmp = new Bitmap(100, 30);
Graphics g = Graphics.FromImage(bmp);
g.Clear(Color.Navy);
string randomString = CaptchaImageResult.GetCaptchaString(6);
g.DrawString(randomString, new Font("Courier", 16),
new SolidBrush(Color.WhiteSmoke), 2, 2);
HttpResponse response = System.Web.HttpContext.Current.Response;
response.ContentType = "image/jpeg";
bmp.Save(response.OutputStream, ImageFormat.Jpeg);
bmp.Dispose();
new CaptchaChallenge { Captcha = bmp };
Update ..
I tried with this code, but the letters are not clear.
Brush zigzagBrush = new System.Drawing.Drawing2D.HatchBrush(
System.Drawing.Drawing2D.HatchStyle.ZigZag, Color.White);
g.DrawString(randomString, new Font("Courier", 16), zigzagBrush, 2, 2);
source
share