ASP color Verification Code image generation script ~~49 line code! No more simplification.

Source: Internet
Author: User
Tags bmp image
Script | Verification code adode. Stream Complete! 49 lines of code, three files, a bit like the effect of the CGI img.exe on this site
ASP File: code.asp
Data file: Body. Fix, Head.fix
Demonstrate:
Http://www.lfgbox.com/paintblue/code/code.asp
:D I have already put my forum to go ~ ~
Download:
Http://www.lfgbox.com/download/code.rar
Usage:
On quarantine page: Judge Cint (Request ("GetCode")) =session ("GetCode")
: Rolleyes:: rolleyes:: Rolleyes:
Don't blame me for doing extra Labor ~ ~ Toss Code! It's nice to write a brand new stuff.
Please note download the full digital data file ~ ~

The code idea is to use ADODB. Stream binary object for the processing of binary streams!
The randomly generated numbers are converted to the corresponding data blocks in the call image data, and the image data is GBR GBR. Row of data, the head is BMP head ~ ~ Then with ADODB.stream will generate the random digital image data into a new BMP image block ~ ~ with Response.BinaryWrite to send it directly to the browser

Body.fix Digital 0~9 10x100 vertical line of RGB array data 3200 byte
Head.fix is a 54byte BMP head.
If you want to change the font and color ~ ~ can be BMP 10x100 image of the first 54 bytes removed!
Replace the body. Fix file

The following is the program code
<%
Option Explicit
Response.buffer=true
Numcode
Function Numcode ()
Response.Expires =-1
Response.AddHeader "Pragma", "No-cache"
Response.AddHeader "Cache-ctrol", "No-cache"
Dim znum,i,j
Dim ados,ados1
Randomize Timer
Znum = CInt (8999*rnd+1000)
Session ("GetCode") = Znum
Dim zimg (4), NSTR
Nstr=cstr (Znum)
For I=0 to 3
Zimg (i) =cint (Mid (nstr,i+1,1))
Next
Dim Pos
Set Ados=server.createobject ("ADODB.stream")
Ados.mode=3
Ados.type=1
Ados.open
Set Ados1=server.createobject ("ADODB.stream")
Ados1.mode=3
Ados1.type=1
Ados1.open
Ados.loadfromfile (Server.MapPath) ("body." Fix "))
Ados1.write Ados.read (1280)
For I=0 to 3
ados.position= (9-zimg (i)) *320
ados1.position=i*320
Ados1.write Ados.read (320)
Next
Ados.loadfromfile (Server.MapPath ("Head.fix"))
Pos=lenb (Ados.read ())
Ados.position=pos
For i=0 to 9 Step 1
For J=0 to 3
ados1.position=i*32+j*320
ados.position=pos+30*j+i*120
Ados.write Ados1.read (30)
Next
Next
Response.ContentType = "Image/bmp"
Ados.position=0
Response.BinaryWrite Ados.read ()
Ados.Close:set ados=nothing
Ados1.Close:set ados1=nothing
End Function
' Asp code Created by blueidea.com Web team V37 2003-7-25
%>




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.