Solved

Java Comparing Image Files

Posted on 2006-07-20
7
556 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
  • 3
7 Comments
 
LVL 30

Accepted Solution

by:
mayankeagle earned 168 total points
Comment Utility
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
Comment Utility

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:mayankeagle
Comment Utility
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
Comment Utility
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:mayankeagle
Comment Utility
Duh~! I knew I was forgetting that ;-)
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Suggested Solutions

For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:

728 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now