11-18-2022, 09:21 PM
squish the two images down to a really small image. If they don't match when they are 2 by 2 pixels they sure aren't going to match when they are say 200 by 200 pixels.
if it matches keep comparing pixels by pixel in slightly larger scaled image until back up to original size.
crude example:
if it matches keep comparing pixels by pixel in slightly larger scaled image until back up to original size.
crude example:
Code: (Select All)
Screen _NewImage(800, 500, 32)
i1& = _NewImage(200, 200, 32)
i2& = _NewImage(200, 200, 32)
Dim p1 As _Unsigned Long
Dim p2 As _Unsigned Long
Randomize Timer
_Dest i1&
'x1 = Int(Rnd * _Width / 2): x2 = Int(Rnd * _Width / 2 + x1)
'y1 = Int(Rnd * _Height / 2): y2 = Int(Rnd * _Height / 2 + y1)
'Line (x1, y1)-(x2, y2), _RGB32(100, 100, Int(Rnd * 8) + 100), BF
Line (0, 0)-(10, 10), _RGB32(100, 100, 100), BF
_Dest i2&
'x1 = Int(Rnd * _Width / 2): x2 = Int(Rnd * _Width / 2 + x1)
'y1 = Int(Rnd * _Height / 2): y2 = Int(Rnd * _Height / 2 + y1)
'Line (x1, y1)-(x2, y2), _RGB32(100, 100, Int(Rnd * 8) + 100), BF
Line (0, 0)-(10, 11), _RGB32(100, 100, 100), BF
_Dest 0
_PutImage (0, 201), i1&
_PutImage (201, 201), i2&
flagcount = 0
threshold = 2
pass = 0
For xmax = 2 To _Width(i1&) Step 10
pass = pass + 1
Locate 1, 1: Print pass 'this really just gives you something to look at
For ymax = 2 To _Height(i1&) Step 10
_Limit 100
a& = _NewImage(xmax, ymax)
b& = _NewImage(xmax, ymax)
_PutImage (0, 0)-(xmax, ymax), i1&, a&, (0, 0)-(_Width(i1&), _Height(i1&))
_PutImage (0, 0)-(xmax, ymax), i2&, b&, (0, 0)-(_Width(i2&), _Height(i2&))
For py = 1 To ymax
For px = 1 To xmax
_Source a&
p1 = Point(px, py)
_Source b&
p2 = Point(px, py)
If p1 <> p2 Then flagcount = flagcount + 1
If flagcount >= threshold Then GoTo notthesame
Next
Next
Next
Next
Locate 2, 2
Print "IMAGES are IDENTICAL"
End
notthesame:
Locate 2, 2
Print "IMAGES ARE NOT IDENTICAL"