Solved

Java Comparing Image Files

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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
V.simple question about Android packages and libraries 1 18
JDeveloper 12c for 32 bit 4 84
more than one jdk and one jre 1 41
Windows 10 IE Certificate Issue 10 45
INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
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 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:
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

813 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

17 Experts available now in Live!

Get 1:1 Help Now