Java Comparing Image Files

I would like to create an java program which interacts with another application on my desktop, by frequently taking screenshot and comparing this with the last screenshot, the program should be able to detmind what if anything has changed and than act accordingly.

I have worked out that i can take screenshots using the robot class and store them into a BufferedImage but how do i now compare the two files, it would be useful to break the image down into manageable chunks.

Thanks for any help you are able to offer me.
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

Mayank SConnect With a Mentor Associate Director - Product EngineeringCommented:
You can get pixels from a buffered-image using this:

- and then compare both the files, if that helps.
mukundha_expertConnect With a Mentor Commented:

if you can get all the pixels in a array like in that example, then you can compare them using Arrays.equals()
Mayank SAssociate Director - Product EngineeringCommented:
If you have them saved in a file, you can also try some file-comparision utility.
girionisConnect With a Mentor Commented:
Hi sjw11

You can use a PixelGrabber and compare the pixels fo the images one by one. Just make sure you are encoding the images with the same algorithm (jpeg, bmp etc) every time.

Mayank SAssociate Director - Product EngineeringCommented:
Duh~! I knew I was forgetting that ;-)
All Courses

From novice to tech pro — start learning today.