CompareBitmaps> functionality questions

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
spar108r
Newbie
Posts: 13
Joined: Tue Oct 24, 2006 12:10 am
Location: Toronto, Ontario, Canada

CompareBitmaps> functionality questions

Post by spar108r » Tue Jan 02, 2007 5:16 pm

Hello,

Image
Image
Image
Image

I'm having a little bit of an issue with the CompareBitmaps> function

I'm trying to compare the attached 2 bmp files (grouptelecom*.bmp) which are very noticeably different and I'm always getting a 100% match yet when I compare the other 2 that are attached which are also slightly visibly different (bellon*.bmp) it's not 100% which is accurate.

Can you let me know why the grouptelecom files are considered the same by CompareBitmaps> and the other two are not.

Thanks in advance,
Dean[/img]

rawill
Newbie
Posts: 15
Joined: Fri Feb 23, 2007 7:06 am
Location: Australia

Post by rawill » Sat Feb 23, 2008 5:14 am

Firstly sorry to dig up this thread, but better recycled than new :)

I am also having this issue.

I read that in version 9.2 this could be an issue due to rounding but was subsequently fixed.

I'm now using Version 10 and for the life of me I still cannot get my two bitmaps to return me a decent match.

Currently I capture a small part of the screen which changes every 20 seconds. C1 would capture before the cycle, C2 after the cycle.

When I pause to compare the two bitmaps, I get a 100% match.

Here they are...


http://users.on.net/~rawill/Pics/c1.bmp
http://users.on.net/~rawill/Pics/c2.bmp

Thanks to anyone who can shed some light on this.
Last edited by rawill on Sat Feb 23, 2008 11:34 am, edited 1 time in total.

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Sat Feb 23, 2008 9:41 am

Those are identical, because they are in fact the exact same file. They both link to the same place. It is possible that both your bitmaps contain exactly the same number of colors and pixels (though not exactly in the same place).

There's a much quicker, easier, way to compare two identically sized bitmaps if all you want to do is know whether they are different or not - just compare the MD5 checksum of the bitmap files themselves. Use the Hash library and compare the MD5 checksum of each bitmap. If the images are different the MD5 hash will differ. If they are identical the MD5 hash of the bitmap files will be identical. You can download the Hash library here:

http://www.mjtnet.com/plugins.htm

Here's an example that compares the two bitmap files:

Code: Select all

//Get MD5 hash of a file
LibFunc>d:\Hashlib,FileMD5,r1,D:\img\screen.bmp,buf1
Mid>r1_2,1,r1,hash1

//Get MD5 hash of a file
LibFunc>d:\Hashlib,FileMD5,r2,D:\img\screen2.bmp,buf2
Mid>r2_2,1,r2,hash2

If>hash1=hash2
  MessageModal>Bitmap files are identical
else
  MessageModal>Bitmap files are different
Endif
A precise graphical comparison is slower, but can be achieved with the GetRectCheckSum commands. This works directly off the screen and allows you to define a rectangular portion of the screen and get a checksum back based on the position/color of each pixel.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

rawill
Newbie
Posts: 15
Joined: Fri Feb 23, 2007 7:06 am
Location: Australia

Post by rawill » Sat Feb 23, 2008 11:34 am

Apoligies.

I tried about 8 different times to get my images to link and it appears on the last go I stuffed them up and linked the same file twice.

I couldn't get the img tags to work.

I have updated my original post with the correct links.
Last edited by rawill on Tue Feb 26, 2008 12:36 am, edited 1 time in total.

rawill
Newbie
Posts: 15
Joined: Fri Feb 23, 2007 7:06 am
Location: Australia

Post by rawill » Sun Feb 24, 2008 1:32 am

NOthing to see here :wink:
Last edited by rawill on Tue Feb 26, 2008 12:37 am, edited 1 time in total.

rawill
Newbie
Posts: 15
Joined: Fri Feb 23, 2007 7:06 am
Location: Australia

Post by rawill » Sun Feb 24, 2008 6:58 am

GetRectCheckSum is working great now, it definitely seems to be more accurate than CompareBitmaps.

Currently I use them both in combination. Mostly because I need to refer to static screen captures for some if statements.

Now that everything is running smoothly I added in a function to write results to a .txt file that gets converted to a .html file and uploaded via ftpput to my website.

Now I can watch my macro progress from work 8)

Thanks for your reply Marcus.

Here is my checksum compare script very basic, but it does the job.

Code: Select all

GetRectCheckSum>195,638,230,644,C1
Wait>7
GetRectCheckSum>195,638,230,644,C2
If>C1=C2
MessageModal>Is the same - C1: %C1% - C2: %C2%
Else
MessageModal>Is different - C1: %C1% - C2: %C2%
Endif

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts