Here you can find the source of equals(BufferedImage img1, BufferedImage img2)
public static boolean equals(BufferedImage img1, BufferedImage img2)
//package com.java2s; /*//from w ww .j a v a2 s . c om Copyright (c) 2006 Harri Kaimio This file is part of Photovault. Photovault is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. Photovault is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with Photovault; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ import java.awt.image.*; public class Main { /** Returns true if the 2 images are equal, false otherwise */ public static boolean equals(BufferedImage img1, BufferedImage img2) { if (img1.getWidth() != img2.getWidth()) { return false; } if (img1.getHeight() != img2.getHeight()) { return false; } System.err.println("Equal size"); int[] data1 = img1.getRGB(0, 0, img1.getWidth(), img1.getHeight(), null, 0, img2.getWidth()); int[] data2 = img2.getRGB(0, 0, img2.getWidth(), img2.getHeight(), null, 0, img2.getWidth()); // Compare the images pixel by pixel int diffCount = 0; for (int n = 0; n < data1.length; n++) { if (data1[n] != data2[n]) { diffCount++; } } return (diffCount < 10) ? true : false; } }