Graph g = graph. FromImage;
attempt
{
//Generate a random generator
Random Random = new Random();
//Clear the background color of the picture.
G. transparent (color. White);
//Draw the background noise line of the picture.
for(int I = 0; I & lt25; i++)
{
int x 1 = random。 Next (picture. Width);
Int x2 = random. Next (picture. Width);
int y 1 = random。 Next (picture. Height);
Int y2 = random. Next (picture. Height);
G.DrawLine (new pen (color. Silver), x 1, y 1, x2, y2);
}
Font font = new Font("Arial ", 12,(FontStyle。 Bold | FontStyle. Italic));
Lineargradientbrush = new lineargradientbrush (new rectangle (0,0, image). Width, image. Height), color. Red, color. Crimson, 1.2f, true);
G. pull rope (checkCode, font, brush, 0,0);
//Draw the foreground noise of the picture.
for(int I = 0; I< 100; i++)
{
int x = random。 Next (picture. Width);
int y = random。 Next (picture. Height);
Image. SetPixel(x,y,Color。 FromArgb (random. next()));
}
//Draw the border line of the picture
G.DrawRectangle (new pen (color. Silver), 0, 0, image. Width-1, image. Height-1);
System. IO.MemoryStream ms = new system. IO . memory stream();
Image. Save (ms, system. drawing . imaging . image format . gif);
Response. clear content();
Response. content type = " image/Gif ";
Response. binary write(ms . ToArray());
}
finally
{
g.dispose();
Image. dispose();
}
I hope it helps you.