Java BufferedImage Operation areBufferedImagesEqual(BufferedImage img1, BufferedImage img2)

Here you can find the source of areBufferedImagesEqual(BufferedImage img1, BufferedImage img2)

Description

are Buffered Images Equal

License

Open Source License

Declaration

public static boolean areBufferedImagesEqual(BufferedImage img1, BufferedImage img2) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.awt.image.BufferedImage;

public class Main {
    public static boolean areBufferedImagesEqual(BufferedImage img1, BufferedImage img2) {
        if (img1 == null && img2 == null) {
            return true;
        } else if (img1 == null || img2 == null) {
            return false;
        } else if (img1.getWidth() == img2.getWidth() && img1.getHeight() == img2.getHeight()) {
            for (int x = 0; x < img1.getWidth(); x++) {
                for (int y = 0; y < img1.getHeight(); y++) {
                    if (img1.getRGB(x, y) != img2.getRGB(x, y)) {
                        return false;
                    }/*from  w  ww.  ja v  a2s .c o m*/
                }
            }
        } else {
            return false;
        }
        return true;
    }
}

Related

  1. applyGrayDecode(BufferedImage rgbImage, int bitsPerComponent, float[] decode)
  2. applyGrayscaleMaskToAlpha(BufferedImage image, BufferedImage mask)
  3. applyMask(BufferedImage img, Color keyColor)
  4. applyMaskImage(BufferedImage src, int x, int y, int w, int h)
  5. applyShadow(BufferedImage image)
  6. autoPanImage(BufferedImage img, Color bgcolor)
  7. binarize(BufferedImage image)
  8. binarize(BufferedImage original)
  9. binary(BufferedImage src)