正好有这个例子 好久前写的了 '************************************************************************** ' SAVE DATA '************************************************************************** rivate Sub Command1_Click() Dim i As Integer Dim j As Integer Dim s As Long Dim x As Long s = 1 Open App.Path & "\Pic.Int" For Binary As #1
For i = Picture1.ScaleLeft To Picture1.ScaleLeft + Picture1.ScaleWidth For j = Picture1.ScaleTop To Picture1.ScaleTop + Picture1.ScaleHeight If Picture1.Point(i, j) >= QBColor(7) Then x = 1 Else x = 0 End If Put #1, s, x s = Seek(1) DoEvents Next
Next Close #1 MsgBox "OK"
End Sub '************************************************************************** ' LOAD DATA '************************************************************************** Private Sub Command2_Click() Dim i As Integer Dim j As Integer Dim s As Long Dim x As Long s = 1 Open App.Path & "\Pic.Int" For Binary As #1 For i = Picture1.ScaleLeft To Picture1.ScaleLeft + Picture1.ScaleWidth For j = Picture1.ScaleTop To Picture1.ScaleTop + Picture1.ScaleHeight Get #1, s, x s = Seek(1) If x = 0 Then Picture1.PSet (i, j), QBColor(15) Else Picture1.PSet (i, j), QBColor(0) End If
Next Next
Close #1
End SubPrivate Sub Form_Load() Picture1.Picture = LoadPicture("") End Sub
不过你打算用什么样的数据结构存储这些信息?
好久前写的了
'**************************************************************************
' SAVE DATA
'**************************************************************************
rivate Sub Command1_Click()
Dim i As Integer
Dim j As Integer
Dim s As Long
Dim x As Long
s = 1
Open App.Path & "\Pic.Int" For Binary As #1
For i = Picture1.ScaleLeft To Picture1.ScaleLeft + Picture1.ScaleWidth
For j = Picture1.ScaleTop To Picture1.ScaleTop + Picture1.ScaleHeight
If Picture1.Point(i, j) >= QBColor(7) Then
x = 1
Else
x = 0
End If
Put #1, s, x
s = Seek(1)
DoEvents
Next
Next
Close #1
MsgBox "OK"
End Sub
'**************************************************************************
' LOAD DATA
'**************************************************************************
Private Sub Command2_Click()
Dim i As Integer
Dim j As Integer
Dim s As Long
Dim x As Long
s = 1
Open App.Path & "\Pic.Int" For Binary As #1
For i = Picture1.ScaleLeft To Picture1.ScaleLeft + Picture1.ScaleWidth
For j = Picture1.ScaleTop To Picture1.ScaleTop + Picture1.ScaleHeight
Get #1, s, x
s = Seek(1)
If x = 0 Then
Picture1.PSet (i, j), QBColor(15)
Else
Picture1.PSet (i, j), QBColor(0)
End If
Next
Next
Close #1
End SubPrivate Sub Form_Load()
Picture1.Picture = LoadPicture("")
End Sub