Delphi Verification Code Image generation, modified from "Celebrities: 517165547"

Source: Internet
Author: User

function Generateverifycode (var code:string): Tbitmap;
Var
I,j,k:integer;
Vpoint:tpoint;
Vleft:integer;
Arrstr:array [1..36]of string;
Vcodebmp:tbitmap;
pwdimgstr:string;
Begin
Pwdimgstr:= ";
arrstr[1]:= ' 0 '; arrstr[2]:= ' 1 '; arrstr[3]:= ' 2 '; arrstr[4]:= ' 3 ';
arrstr[5]:= ' 4 '; arrstr[6]:= ' 5 '; arrstr[7]:= ' 6 '; arrstr[8]:= ' 7 ';
arrstr[9]:= ' 8 '; arrstr[10]:= ' 9 '; arrstr[11]:= ' A '; arrstr[12]:= ' B ';
arrstr[13]:= ' C '; arrstr[14]:= ' D '; arrstr[15]:= ' E '; arrstr[16]:= ' F ';
arrstr[17]:= ' G '; arrstr[18]:= ' H '; arrstr[19]:= ' I '; arrstr[20]:= ' J ';
arrstr[21]:= ' K '; arrstr[22]:= ' L '; arrstr[23]:= ' M '; arrstr[24]:= ' N ';
arrstr[25]:= ' O '; arrstr[26]:= ' P '; arrstr[27]:= ' Q '; arrstr[28]:= ' R ';
arrstr[29]:= ' S '; arrstr[30]:= ' T '; arrstr[31]:= ' U '; arrstr[32]:= ' V ';
arrstr[33]:= ' W '; arrstr[34]:= ' X '; arrstr[35]:= ' Y '; arrstr[36]:= ' Z ';
For J:=1 to 4 do
Begin
Randomize;
K:=strtoint (Format ('%.1d ', [Random (36)]));
Pwdimgstr:=pwdimgstr+trim (Arrstr[k])
End
vleft:=10;
Vcodebmp:=tbitmap.create;
Vcodebmp. width:=73;
Vcodebmp. height:=25;

For i:= 1 to Length (PWDIMGSTR) do
Begin
With Vcodebmp do
Begin
Canvas.Font.Size: = Random (10) + 9;

Canvas.Font.Color: = RGB (Random () and $C 0,
Random (n) and $C 0,random and $C 0);
If Random (2) =1 Then
Canvas.Font.Style: = [Fsbold]
else Canvas.Font.Style: = [];
Begin
Canvas.Font.Name: = screen.fonts[10];
Vpoint.x: = Random (4) + vleft;
Vpoint.y: = Random (5);
Canvas.textout (Vpoint.x,vpoint.y,pwdimgstr[i]);
Vleft: = Vpoint.x + canvas.textwidth (Pwdimgstr[i]);
End
End
End
CODE:=PWDIMGSTR;
Result:= vcodebmp;

End

Delphi Verification Code Image generation, modified from "Celebrities: 517165547"

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.