|
以下是我用文件对BITMAP进行比较的方法.
但是这种方法只能比较两张图片的全部.不能比较比较图片中的部分区域.
LcdDlgTitle = "LCD Device(μPD16432B)"
LcdDlgTitle1 = "LCD1 Device(μPD16432B)"
dialog(LcdDlgTitle ).CaptureBitmap "c:\lcd.bmp",true
dialog(LcdDlgTitle1 ).CaptureBitmap "c:\lcd1.bmp",true
Dim FS, File1, File2
FilePath1 = "c:\lcd.bmp"
FilePath2 = "c:\lcd2.bmp"
Set FS = CreateObject("Scripting.FileSystemObject")
If ( FS.GetFile(FilePath1).Size <> FS.GetFile(FilePath2).Size) Then
msgbox "FilePath1:=" & FS.GetFile(FilePath1).Size & "endl"
msgbox "FilePath2:=" & FS.GetFile(FilePath2).Size & "endl"
CompareFiles = 1
'Exit Function
End If
Set File1 = FS.GetFile(FilePath1).OpenAsTextStream(1, 0)
Set File2 = FS.GetFile(FilePath2).OpenAsTextStream(1, 0)
CompareFiles = False
Do While File1.AtEndOfStream = False
Str1 = File1.Read(1000)
Str2 = File2.Read(1000)
CompareFiles = StrComp(Str1, Str2, 0)
If CompareFiles <> 0 Then
CompareFiles = 1
Exit Do
End If
Loop
File1.Close()
File2.Close()
通过像素点的比较
Dim mybmp1
Dim mybmp2
Set mybmp1 = LoadPicture ("c:\lcd.bmp")
Set mybmp2 = LoadPicture ("c:\lcd1.bmp")
msgbox mybmp1.Height
msgbox mybmp1.Width
For Y = 0 To mybmp1.Height
For X = 0 To mybmp2.Width
fColor1 = mybmp1.Point(X, Y) '?????????????????????????????????????????????????????????????????????????
fColor2 = mybmp2.Point(X, Y)
if fColor1<>fColor2 then
msgbox "不一样!"
End If
Next 'X
Next 'Y |
|