Graphical verification code and asp.net graphic verification code drawn in ASP. NET

Source: Internet
Author: User

Graphical verification code and asp.net graphic verification code drawn in ASP. NET

1 context. response. contentType = "image/jpeg "; 2 // generate a random Chinese verification code. 3 string yzm = "population, hands, numbers, numbers nanchang Donghai Xi'an is the shahe High Education Park "4 +" Mu he up and down earth eight into the sky fire text six seven Son nine loose day of the sub-door month don't open four or five ears head rice see white field electricity also Changshan out of the Flying Horse, birds, cloud bus, cattle, sheep, little towel, teeth, feet, hair, heart, hand, water, wide-up foot "5 +" take the square half Ba industry, this book, their own things back to the skin of the fruit with the rain of fish today two melon clothing about the next year Ding Qi Winter say friends spring friends high you green flowers red grass ye Jie's old line of ancient sound zhiduo busy wash really look father sweep "6 + "when my mom and dad finish writing, my Mom and Dad will watch the pictures with a smile and enjoy the music and enjoy the morning. When the girl gets angry, she goes to the light and Li yuxiu Qianxiang to listen to the music and decide to start with her later. ganming catch up with the specialist team ant front chamber empty net poetry Huang Lin closed "7 +" Tong Li is my flower ye Meiji, she sent it when he passed it to it. what if I borrow my sister? Who is cool, who is afraid of traffic and the most garden face? Because Yang is light, FA SHI is looking for a way to handle Xu, and that's all scared to make it look like a photo like sha haiqiao Jun bamo Jing Xiang" 8 + "I forgot to Miss Wang. Here, I went to the edge and said," Bei, male, old man, love shrimp, play music, play music, and learn. "I often asked my colleagues about it ." group steam points do not have children to choose north Hunan Qiu Jiang only help stars please snow on the ball jump play "9 +" Peach Tree gang LAN seat each take sit in an emergency name turned into a new late what is changing"; 10 Random r = new Random (); 11 string validCode = ""; 12 for (int I = 0; I <4; I ++) 13 {14 int number = r. next (0, yzm. length); 15 validCode + = yzm [number]; 16} 17 18 // drawing 19 using (Bitmap B = new Bitmap (150, 30 )) 20 {21 using (Graphics g = Graphics. fromImage (B) 22 using (Font f = new Font ("", 20) 23 {24g. clear (Color. yellow); // clear the entire painting surface and fill in the specified background color for 25 GB. drawString (validCode, f, Brushes. red, new PointF (0, 0); // start to draw 26 // foreground 27 for (int I = 0; I <100; I ++) 28 {29 int x = r. next (0,150); 30 int y = r. next (0, 30); 31 B. setPixel (x, y, Color. red); 32} 33 // background line 34 for (int I = 0; I <100; I ++) 35 {36 int x = r. next (0,150); 37 int y = r. next (0, 30); 38g. drawLine (Pens. red, x, y, x + 1, y + 1); 39} 40} 41 B. save (context. response. outputStream, ImageFormat. jpeg); // save it to the output stream 42}

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.