Fix is a derivative format of bmp and can be used for asp to generate Verification Code graphics.

Source: Internet
Author: User
Tags bmp image
Fix is a derivative format of bmp and can be used for asp to generate Verification Code graphics.

14:50:36 | category: technical materials | tags: | font size, large, and small subscriptions

The body. fix and head. fix files in ASP source code are now available. It is related to the verification code. To fully understand this, we need to understand the encoding of the bmp Format Image File.
The content of the first 54Byte In the bmp file is the header information. You can use a program or tool to read the content of the 54Bye and save it as the head. fix file. In addition to the 54Byte data, this is the RGB array data, which is saved as the body. fix file.
CHECKCODE. the ASP program starts from the body. read a small display data combination in the fix, and then use it with the head. the data in the fix is combined into an image and then sent to the browser to display the image verification code.
Therefore, the. fix file is only used to save a bunch of useful data files, and uses CHECKCODE. ASP to read the data in it.
How to create a file ??

Use a program to read the binary data of a file, specify where to read and how much to read, and then save the read data.
The Adodb. Stream object in ASP can perform this task well.

That is to say, the *. fix file is generated after being compiled by a program.
It is not generated by any drawing tool.

First, use the image editing software to edit and save the beautiful image. Then, use programming to read the image and break it into two files.

Example:
1. After the image is drawn, save the file as a BMP image file in 24-Bit Bitmap format.
2. Remove the first 54Byte.
3. Change the name to BODY + number. FIX.
4. Modify CHECKCODE. ASP and call the newly created file.
(Checkcode. asp is responsible for generating and outputting the verification code 1309 byte. head. fix is the BMP header of 54byte, and body. fix number 0 ~ 9 10x3200 vertical RGB array data bytes)

Is the file that generates the color verification code.

1. checkcode. ASP is responsible for generating and outputting the verification code 1309 bytes.
2. head. fix is the BMP header of 54byte.
3. body. fix number 0 ~ 9 10x3200 vertical RGB array data bytes

Fix is a derivative format of bmp and can be used for asp to generate Verification Code graphics.

Example:
1. After the image is drawn, save the file as a BMP image file in 24-Bit Bitmap format.
2. Remove the first 54Byte.
3. Change the name to BODY + number. FIX.
4. Modify CHECKCODE. ASP and call the newly created file.
(Checkcode. asp is responsible for generating and outputting the verification code 1309 byte. head. fix is the BMP header of 54byte, and body. fix number 0 ~ 9 10x3200 vertical RGB array data bytes)

Is the file that generates the color verification code.

1. checkcode. ASP is responsible for generating and outputting the verification code 1309 bytes.
2. head. fix is the BMP header of 54byte.
3. body. fix number 0 ~ 9 10x3200 vertical RGB array data bytes
Program code
<% Option Explicit
Response. buffer = True
NumCode (14)
Function NumCode (CodeType)
Response. Expires =-1
Response. AddHeader "Pragma", "no-cache"
Response. AddHeader "cache-ctrol", "no-cache"
On Error Resume Next
Dim zNum, rNum, I, j, listnum, listcode
Dim Ados, Ados1
Listcode = "0123456789 abcdefghijklmnopqrstuvwxyz"
Randomize Timer
Dim zimg (6), NStr
For I = 0 To 5
RNum = CStr (CInt (9 * Rnd ))
Zimg (I) = rNum
Listnum = listnum & Mid (listcode, rNum + 1, 1)
Next
Session ("CheckCode") = listnum
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" & CodeType & ". Fix "))
Ados1.write Ados. read (2880), followed by 2880
For I = 0 To 5
Ados. Position = (35-zimg (I) * 480 what is the role of 35-zimg (I) and their relationship?
Ados1.Position = I * 480
Ados1.write Ados. read (1, 480)
Next
Ados. LoadFromFile (Server. mappath ("head. fix "))
Pos = LenB (Ados. read ())
Ados. Position = Pos
For I = 0 To 15 Step 1 Why is the loop only 15, and below To 5, there is another 32,480,270, 30 I don't understand what these numbers do! Can anyone tell me?
For j = 0 To 5
Ados1.Position = I x 32 + j x 480
Ados. Position = Pos + 30 * j + I * 270
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
'If Err Then Session ("CheckCode") = "999999"
End Function
%>

 

Http://xiayankun.blog.163.com/blog/#m=0

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.