今天看到一個用ASP程序編寫一個bmp圖片格式的五星紅旗,像手繪的一樣,很好,把它轉過來和大家分享
001
<%
002
Option Explicit
003
Class FiveStarredFlag
004
PRivate Width
005
Private Height
006
Private Filler
007
Private SizeImage
008
Private FileSize
009
Private BitMap()
010
011
Private Sub Class_Initialize
012
Height = 200
013
Width = 300
014
Filler = (32 - Width Mod 32) Mod 32
015
SizeImage = (Width + Filler) * Height \ 8
016
FileSize = SizeImage + 14 + 40 + 8
017
018
ReDim BitMap(Width + Filler - 1, Height - 1)
019
020
Star Height * 0.25, Height * 0.75, Height * 0.15, 0
021
Star Width / 3, Height * 0.9, Height * 0.05, 120.9637565320735
022
Star Width * 0.4, Height * 0.8, Height * 0.05, 98.13010235415598
023
Star Width * 0.4, Height * 0.65, Height * 0.05, 74.0546040990771
024
Star Width / 3, Height * 0.55, Height * 0.05, 51.3401917459099
025
End Sub
026
027
Private Sub Class_Terminate
028
Response.ContentType =
"image/bmp"
029
Response.BinaryWrite FileHeader & InfoHeader & Palette & ImageData
030
031
032
Private Sub Star(x, y, r, a)
033
Dim pi, v, d, i, j, k, m2
034
035
pi = 3.1415926535897932
036
v = r * Sin(pi * 0.1) / Sin(pi * 0.7)
037
038
For j = -r To r
039
For i = -r To r
040
d = Sqr(i ^ 2 + j ^ 2)
041
042
If d < v Then
043
BitMap(x + i, y + j) = 1
044
ElseIf d < r Then
045
If i = 0 Then
046
If j > 0 Then k = 90 Else k = -90
047
Else
048
k = Atn(j / i) * 180 / pi
049
If i < 0 Then k = k + 180
050
End If
051
052
k = k - a - 18
053
While k < 0
054
k = k + 360
055
Wend
056
While k >= 360
057
k = k - 360
058
059
While k >= 72
060
k = k - 72
061
062
If k > 36 Then k = 72 - k
063
064
m2 = d ^ 2 + r ^ 2 - d * r * 2 * Cos(k * pi / 180)
065
If (m2 + r ^ 2 - d ^ 2) / (Sqr(m2) * r * 2) > Cos(pi * 0.1) Then
066
067
068
069
Next
070
071
072
073
Private Function CWord(I16)
074
CWord = ChrB(I16 And &HFF) & ChrB(I16 \ 256 And &HFF)
075
End Function
076
077
Private Function CDWord(I32)
078
CDWord = ChrB(I32 And &HFF) & ChrB(I32 \ 256 And &HFF) & ChrB(I32 \ 65536 And &HFF) & ChrB(I32 \ &HFFFFFF And &HFF)
079
080
081
Private Property Get FileHeader
082
Const FileType = &H4D42
083
Const Reserved1 = 0
084
Const Reserved2 = 0
085
Const OffBits = 62
086
FileHeader = CWord(FileType) & CDWord(FileSize) & CWord(Reserved1) & CWord(Reserved2) & CDWord(OffBits)
087
End Property
088
089
Private Property Get InfoHeader
090
Const InfoSize = 40
091
Const Planes = 1
092
Const BitCount = 1
093
Const Compression = 0
094
Const XPelsPerMeter = 0
095
Const YPelsPerMeter = 0
096
Const ClrUsed = 0
097
Const ClrImportant = 0
098
InfoHeader = CDWord(InfoSize) & CDWord(Width) & CDWord(Height) & CWord(Planes) & CWord(BitCount) & CDWord(Compression) & CDWord(SizeImage) & CDWord(XPelsPerMeter) & CDWord(YPelsPerMeter) & CDWord(ClrUsed) & CDWord(ClrImportant)
099
100
101
Private Property Get Palette
102
Const BackColor = &HFF0000
103
Const ForeColor = &HFFFF00
104
Palette = CDWord(BackColor) & CDWord(ForeColor)
105
106
107
Private Property Get ImageData
108
Dim i, j
109
ImageData =
""
110
For j = 0 To Height - 1
111
For i = 0 To Width + Filler - 1 Step 8
112
ImageData = ImageData & ChrB(BitMap(i, j) * 128 or BitMap(i + 1, j) * 64 or BitMap(i + 2, j) * 32 or BitMap(i + 3, j) * 16 or BitMap(i + 4, j) * 8 or BitMap(i + 5, j) * 4 or BitMap(i + 6, j) * 2 or BitMap(i + 7, j))
113
114
115
116
End Class
117
118
With New FiveStarredFlag
119
End With
120
%>
雖然Windows 7的正式版還沒有發布,但大家對測試版的
在這一點上,開發組實現了開始這個項目時所定的目標。現存的客
作為動態網站在建設過程中難免遇到在線編輯文章的問題。HTM
對於鍵盤流而言,自然是恨不得所有操作都能通過鍵盤快捷鍵來完
自從買了PPC以後每
學習目的:安裝調試ASP的環境,寫出第一個HELLO WO