Without refreshing the Google waveform distortion color Asp.net Verification Code

Source: Internet
Author: User

There are many examples of Asp.net verification codes on the Internet. Some time ago, my "Asp.net brushless New Chinese verification codes implemented by 51aspx" was reprinted by many websites, however, there is no need to update the image and the waveform is distorted.ArticleThere are very few examples, and they are almost difficult to find. So I collected some materials and wrote an example for free. The main features are as follows:

:

 Refreshing:That is to say, a JS script can be used for the "cannot see clearly, click to change" and "Change verification code" functions of websites!
 Waveform distortion:Similar to Google's verification code, this is more effective to prevent the verification code from being cracked by robots. You can set the specific distortion degree on your own (the sine curve wave will distort the image to generate a waveform filter effect ), adding parameters can also be changed to those of MSN. Let's just put it apart!

 Color:The character colors are random.
 Case sensitivity:It is also random. Of course, you can modify the case for input convenience.
 Note details:Parameters are described in detail and easy to use.

To display the distortion effect, the default font size is 40 pixels, which can be modified by yourself.

Distorted source code:

1 /**/ ///   <Summary>
2 /// Sine Wave distorted image (edit by 51aspx.com)
3 ///   </Summary>
4 ///   <Param name = "srcbmp"> Image path </Param>
5 ///   <Param name = "bxdir"> True if distorted </Param>
6 ///   <Param name = "nmultvalue"> The amplitude multiple of the waveform. The larger the waveform is, the higher the distortion is. Generally, it is 3. </Param>
7 ///   <Param name = "dphase"> Start phase of the waveform, value range [0-2 * PI) </Param>
8 ///   <Returns> </returns>
9 Public System. Drawing. Bitmap twistimage (Bitmap srcbmp, Bool Bxdir, Double Dmultvalue, Double Dphase)
10 {
11 System. Drawing. Bitmap destbmp =   New Bitmap (srcbmp. Width, srcbmp. Height );
12
13 // Fill the bitmap background in white
14 System. Drawing. Graphics Graph = System. Drawing. Graphics. fromimage (destbmp );
15 Graph. fillrectangle ( New Solidbrush (system. Drawing. color. White ), 0 , 0 , Destbmp. Width, destbmp. Height );
16 Graph. Dispose ();
17
18 Double Dbaseaxislen = Bxdir ? ( Double ) Destbmp. Height :( Double ) Destbmp. width;
19
20 For ( Int I =   0 ; I < Destbmp. width; I ++ )
21 {
22 For ( Int J =   0 ; J < Destbmp. height; j ++ )
23 {
24 Double DX =   0 ;
25 DX = Bxdir ? (Pi2 * ( Double ) J) / Dbaseaxislen: (Pi2 * ( Double ) I) / Dbaseaxislen;
26 DX + = Dphase;
27 Double Dy = Math. Sin (dx );
28
29 // Obtains the color of the current vertex.
30 Int Noldx =   0 , Noldy =   0 ;
31 Noldx = Bxdir ? I + ( Int ) (DY * Dmultvalue): I;
32 Noldy = Bxdir ? J: J + ( Int ) (DY * Dmultvalue );
33
34 System. Drawing. color = Srcbmp. getpixel (I, j );
35 If (Noldx > =   0   && Noldx < Destbmp. Width
36 && Noldy > =   0   && Noldy < Destbmp. Height)
37 {
38Destbmp. setpixel (noldx, noldy, color );
39}
40 }
41 }
42
43 Return Destbmp;
44 }
45

I have found a lot of complicated articles about the problem of no refreshing, and then I came up with a simple method. < IMG ID = " Imgverify " SRC = " Verifycode. aspx? " ALT = " Can't see clearly? Click Change " Onclick = " This. src = This. SRC + '? ' "   />

Section JSCodeWell, I don't know if other people have any comments? Welcome

Download sample source code

Note: This article is the first release of the blog Park. For the source code or article reprinted, please indicate the source (liudao.cnblogs.com or www.51aspx.com)

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.