Java BufferedImage Equal imagesEqual(File file1, File file2)

Here you can find the source of imagesEqual(File file1, File file2)

Description

images Equal

License

Open Source License

Declaration

public static boolean imagesEqual(File file1, File file2) throws IOException 

Method Source Code


//package com.java2s;
import java.io.*;
import java.awt.image.BufferedImage;
import javax.imageio.ImageIO;

public class Main {
    public static boolean imagesEqual(File file1, File file2) throws IOException {
        BufferedImage image1 = ImageIO.read(file1);
        BufferedImage image2 = ImageIO.read(file2);
        int columns = image1.getWidth();
        int rows = image1.getHeight();
        for (int row = 0; row < rows; ++row) {
            for (int col = 0; col < columns; ++col) {
                int rgb1 = image1.getRGB(col, row);
                int rgb2 = image2.getRGB(col, row);
                if (rgb1 != rgb2) {
                    return false;
                }/*from w  w  w . ja  va  2  s  . c  o  m*/
            }
        }
        return true;
    }
}

Related

  1. equals(BufferedImage a, BufferedImage b)
  2. equals(BufferedImage img1, BufferedImage img2)
  3. equals(final BufferedImage image1, final BufferedImage image2)
  4. imagesAreEqual(BufferedImage image1, BufferedImage image2)
  5. imagesAreEqual(String referenceImagePath, String capturedImagePath, int x, int y, int w, int h)
  6. imgEquals(File imgRef, File img)