?? form1.frm
字號:
VERSION 5.00
Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.2#0"; "COMDLG32.OCX"
Begin VB.Form Form1
Caption = "不規(guī)則窗體數(shù)據(jù)生成器"
ClientHeight = 4710
ClientLeft = 60
ClientTop = 630
ClientWidth = 4200
LinkTopic = "Form1"
ScaleHeight = 4710
ScaleWidth = 4200
StartUpPosition = 2 '屏幕中心
Begin MSComDlg.CommonDialog CommonDialog1
Left = 0
Top = 0
_ExtentX = 847
_ExtentY = 847
_Version = 393216
CancelError = -1 'True
Flags = 4097
End
Begin VB.PictureBox Picture1
AutoSize = -1 'True
BorderStyle = 0 'None
Height = 4560
Left = 0
Picture = "Form1.frx":0000
ScaleHeight = 304
ScaleMode = 3 'Pixel
ScaleWidth = 192
TabIndex = 0
Top = 0
Visible = 0 'False
Width = 2880
End
Begin VB.Menu 背景顏色
Caption = "背景顏色(&D)"
Begin VB.Menu 背景色
Caption = "黑色"
Index = 0
End
Begin VB.Menu 背景色
Caption = "深藍色"
Index = 1
End
Begin VB.Menu 背景色
Caption = "綠色"
Index = 2
End
Begin VB.Menu 背景色
Caption = "青色"
Index = 3
End
Begin VB.Menu 背景色
Caption = "咖啡色"
Index = 4
End
Begin VB.Menu 背景色
Caption = "紫色"
Index = 5
End
Begin VB.Menu 背景色
Caption = "墨綠色"
Index = 6
End
Begin VB.Menu 背景色
Caption = "灰色"
Index = 7
End
Begin VB.Menu 背景色
Caption = "深灰色"
Index = 8
End
Begin VB.Menu 背景色
Caption = "藍色"
Index = 9
End
Begin VB.Menu 背景色
Caption = "淺綠色"
Checked = -1 'True
Index = 10
End
Begin VB.Menu 背景色
Caption = "淺藍色"
Index = 11
End
Begin VB.Menu 背景色
Caption = "紅色"
Index = 12
End
Begin VB.Menu 背景色
Caption = "粉紅色"
Index = 13
End
Begin VB.Menu 背景色
Caption = "黃色"
Index = 14
End
Begin VB.Menu 背景色
Caption = "白色"
Index = 15
End
End
Begin VB.Menu 開始
Caption = "開始(&O)"
End
Begin VB.Menu 加載圖像
Caption = "加載圖像(&J)"
End
Begin VB.Menu 關(guān)閉
Caption = "關(guān)閉(&C)"
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
'**********************************************
'* Web URL: http://xxlno2vb.yeah.net *
'* 作者: xxlno2 *
'* E-Mail:xxlno2@yeah.net *
'* xxlno2@sina.com *
'* 如有問題請來信聯(lián)系 *
'* 由于程序還不完善,還請多多指教 *
'* 歡迎來信討論VB問題。 *
'**********************************************
'*************不規(guī)則窗體數(shù)據(jù)生成器***
'掃描圖像,生成窗體數(shù)據(jù),提供生成不規(guī)則窗體的需要
'只是生成窗體數(shù)據(jù),需要其它程序配合
'注意屬性設置 ,不然果有差異
'Picture1.Visible = False
'不要PictureBox控件在窗體上面影響掃描后果
' Picture1.ScaleMode = 3 - Pixel
'Picutre1.Picture 加載所要生成窗體數(shù)據(jù)的圖像
'Picture1.AutoSize = True
'使圖片框和圖像一樣大小
'因為該程序需要圖像的像素作掃描圖像的單位
'所以Picture1必須使用像素作為測量單位
'調(diào)節(jié)窗體的大小大于圖像大小,這樣不會圖像掃描不完全
'圖像的背景色最好和圖像的顏色不相同,用特別的色
'注意: 必需當掃描提示出現(xiàn)才可以關(guān)閉程序,否則
' 圖像數(shù)據(jù)會掃描不完全,生成的數(shù)據(jù)不正確
'************************************************
'聲明存放背景色變量
Dim 顏色 As Byte
Private Sub Form_Load()
'把圖片框中的圖像加載到窗體上
Form1.Picture = Picture1.Picture
'初始化背景顏色 為 淺綠色
'范例的圖像的背景顏色為淺綠色
顏色 = 10
End Sub
Private Sub 開始_Click()
Dim Ma As Dat
'生成窗體數(shù)據(jù)文件
'如果想把數(shù)據(jù)文件放在其它位置上可以把修改路徑
Open "d:\Ma.dat" For Random As #1 Len = Len(Ma)
'掃描圖像
For y = 0 To Picture1.ScaleHeight - 1
'初始化變量
Ma.Sx = 0
Ma.Sy = 0
Ma.Ex = 0
Ma.Ey = 0
For x = 0 To Picture1.ScaleWidth - 1
'用函數(shù)從窗體中取得一個像素的RGB值
'如果窗體圖像的坐標(X,Y)不是背景色并且X坐標變量
'還是空白時,記錄區(qū)域的X軸開始位置
If GetPixel(Form1.hdc, x, y) <> QBColor(顏色) And Ma.Sx = 0 Then Ma.Sx = x
'當以經(jīng)記錄區(qū)域的X軸開始位置并且在非背景色渡過背景
'時記錄起區(qū)域的結(jié)束位置
If GetPixel(Form1.hdc, x, y) = QBColor(顏色) And Ma.Sx <> 0 Then
'記錄結(jié)束位置
Ma.Ex = x
'記錄區(qū)域的塊數(shù)
n = n + 1
'記錄區(qū)域的Y軸的開始位置
Ma.Sy = y
'因為矩形區(qū)域是線形的,所以Y軸的結(jié)束位置是在開始
'的Y軸加上1
Ma.Ey = y + 1
'把所測到的窗體數(shù)據(jù)存放入數(shù)據(jù)文件
Put #1, n, Ma
'變量化0
Ma.Sx = 0
Ma.Ex = 0
Ma.Ey = 0
Ma.Sy = 0
End If
Next x
Next y
'提示完成圖像掃描
MsgBox "完成圖像掃描" & Chr(13) & "數(shù)據(jù)文件大小為:" & LOF(1) & "字節(jié)"
'關(guān)閉文件
Close #1
End Sub
Private Sub 背景色_Click(Index As Integer)
'設置背景色
'將打上選擇的符號取消
For i = 0 To 15
背景色(i).Checked = False
Next
'將被子點擊到的選項加上符號
背景色(Index).Checked = True
'背景色的號碼為
顏色 = Index
End Sub
Private Sub 關(guān)閉_Click()
'關(guān)閉生成器程序
Unload Me
End Sub
'加載圖像的設置
'通用型對話框控件屬性Flags為&H1001
'Filter為圖像文件 *.bmp,*.jpg,*.gif,*.ico,*.wmf等
'將通用型對話框控件屬性ComcelError 設為True
Private Sub 加載圖像_Click()
'當在對話框上按下取消時,不加載圖像
On Error GoTo Er
' 設置打開文件的類型
CommonDialog1.Filter = "位圖(*.bmp),Jpg文件|*.bmp;*.jpg"
CommonDialog1.ShowOpen
'把圖像加載到窗體和圖片框上
Picture1.Picture = LoadPicture(CommonDialog1.FileName)
Form1.Picture = Picture1.Picture
Er:
End Sub
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -