Here is just a simple example. The font is also a single font. If you want a better effect, you can set a separate font for each word. Hope to help you
You only need to compare the value of the obtained text box with the value of "session [" valicode.
// Create a bitmap object
Bitmap newbitmap = New Bitmap ( 90 , 22 , Pixelformat. format32bppargb );
// Create a drawing surface based on the position object created above
Graphics g = Graphics. fromimage (newbitmap );
// Fill the rectangle with the specified color
G. fillrectangle ( New Solidbrush (color. White ), New Rectangle ( 0 , 0 , 90 , 22 ));
// Create a font object
Font newfont = New Font ( " Youyuan " , 14 );
// Create a rectanglef structure to specify a region
Rectanglef rectangle = New Rectanglef ( 0 , 0 , 90 , 22 );
// Create random number
Random newrd = New Random ();
String [] ABCD = " I, yes, no, high, day, earth, chat, material, basin, turbidity, small, small, tip, tip, owe, pig, left, leg, knife, eat, thirsty, stick, skin, shadow, rest, grass, camp, save, tax, say, bad, pass, illness, second, world, period, spring, quarter, get, penalty, thing, police, strong, nest, dish, dry, or even, front, cry, pull, noodles, fish, text, ghost, or, hot, dog, egg, hair, pen, network, component, structure, test, social, help, resistance, burn, stick, ping, shoes, board, cutting, flowers, sea, question, A, E, F, R, 9, 0, K, 2, 4, 7, 1, 3, Q, W, Y, U, V, X, P, S, A, D, 8, 5, T " . Split ( ' , ' );
Int Ramstr = Newrd. Next ( 1 , 100 );
Int Ramstr1 = Newrd. Next ( 1 , 100 );
Int Ramstr2 = Newrd. Next ( 1 , 100 );
Int Ramstr3 = Newrd. Next ( 1 , 100 );
String Valinum = ABCD [ramstr] + ABCD [ramstr1] + ABCD [ramstr2] + ABCD [ramstr3]. tostring ();
Session [ " Valicode " ] = Valinum. tostring ();
// Fill the area of the rectangle specified by the rectanglef structure with the specified color
G. fillrectangle ( New Solidbrush (color. burlywood), rectangle );
// Draw random lines
For ( Int II = 0 ; II < 10 ; II ++ )
{
Int X1 = Newrd. Next (newbitmap. Height );
Int Y1 = Newrd. Next (newbitmap. width );
Int X2 = Newrd. Next (newbitmap. Height );
Int Y2 = Newrd. Next (newbitmap. width );
G. drawline ( New Pen (color. Azure), X1, Y2, Y1, X1 );
}
// Fill in the above-filled rectangular area with the random number generated above
G. drawstring (valinum, newfont, New Solidbrush (color. Blue), rectangle );
For ( Int I = 0 ; I < 50 ; I ++ )
{
Int X = Newrd. Next (newbitmap. width );
Int Y = Newrd. Next (newbitmap. Height );
Newbitmap. setpixel (X, Y, color. fromargb (newrd. Next ()));
}
Memorystream MS = New Memorystream ();
Newbitmap. Save (MS, imageformat. GIF );
Response. clearcontent ();
Response. contenttype = " Image/GIF " ;< br>
response. binarywrite (Ms. toarray ();