Solved

Java Comparing Image Files

Posted on 2006-07-20
7
559 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:
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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

For customizing the look of your lightweight component and making it look lucid like it was made of glass. Or: how to make your component more Apple-ish ;) This tip assumes your component to be of rectangular shape and completely opaque. (COD…
Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.

856 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