Сделайте CAPTCHA изображения с перекрывающимися символами в C#
Следующий MakeCaptchaImage2 метод создает Bitmap, содержащий изображение CAPTCHA.
private Random Rand = new Random();
// Рисуем слова с перекрывающимися буквами.
private Bitmap MakeCaptchaImage2(string txt,
int wid, int hgt, Font the_font, Brush the_brush)
{
Bitmap bm = new Bitmap(wid, hgt);
using (Graphics gr = Graphics.FromImage(bm))
{
gr.TextRenderingHint = TextRenderingHint.AntiAliasGridFit;
int x = 0;
foreach (char ch in txt.ToCharArray())
{
SizeF ch_size = gr.MeasureString(ch.ToString(), the_font);
int y = (int)(Rand.NextDouble() * (hgt - ch_size.Height));
gr.DrawString(ch.ToString(), the_font, the_brush, x, y);
x += (int)(ch_size.Width * 0.35);
}
}
return bm;
}
