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作者: walker1020 时间: 2007-4-17 13:07
谢谢 jerryshomaro 为我们提供了 图片比较的方法。如果谁有时间和兴趣,可以研究一下怎么用代码实现对图片中的部分区域的比较。希望各位朋友能多向jerryshomaro 学习!作者: caigua 时间: 2007-4-24 13:03
Set oCompareUtil = CreateObject("Mercury.FileCompare")
oCompareUtil.IsEqualBin(fileExp, fileAct, 0, 1)
这样的不是简单多了么