Solved

Java Comparing Image Files

Posted on 2006-07-20
7
561 Views
Last Modified: 2006-11-18
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.
0
Comment
Question by:sjw11
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
7 Comments
 
LVL 30

Accepted Solution

by:
Mayank S earned 168 total points
ID: 17148536
You can get pixels from a buffered-image using this:

http://javaalmanac.com/egs/java.awt.image/ImagePixel.html

- and then compare both the files, if that helps.
0
 
LVL 10

Assisted Solution

by:mukundha_expert
mukundha_expert earned 166 total points
ID: 17149225

if you can get all the pixels in a array like in that example, then you can compare them using Arrays.equals()
0
 
LVL 30

Expert Comment

by:Mayank S
ID: 17151745
If you have them saved in a file, you can also try some file-comparision utility.
0
 
LVL 35

Assisted Solution

by:girionis
girionis earned 166 total points
ID: 17152250
Hi sjw11

You can use a PixelGrabber http://java.sun.com/j2se/1.4.2/docs/api/java/awt/image/PixelGrabber.html 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.

Cheers
0
 
LVL 30

Expert Comment

by:Mayank S
ID: 17153043
Duh~! I knew I was forgetting that ;-)
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.

696 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question