Java BufferedImage Compare compareImages(final BufferedImage firstImage, final BufferedImage secondImage)

Here you can find the source of compareImages(final BufferedImage firstImage, final BufferedImage secondImage)

Description

compare Images

License

Mozilla Public License

Declaration

protected static boolean compareImages(final BufferedImage firstImage, final BufferedImage secondImage) 

Method Source Code


//package com.java2s;
/*/*from  w  w  w .  j  av a2  s .  co  m*/
 *  This Source Code Form is subject to the terms of the Mozilla Public
 *  * License, v. 2.0. If a copy of the MPL was not distributed with this
 *  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 */

import java.awt.image.BufferedImage;

public class Main {
    protected static boolean compareImages(final BufferedImage firstImage, final BufferedImage secondImage) {
        if (firstImage.getHeight() != secondImage.getHeight() || firstImage.getWidth() != secondImage.getWidth()) {
            return false;
        }

        for (int x = 0; x < firstImage.getWidth(); ++x) {
            for (int y = 0; y < firstImage.getHeight(); ++y) {
                if (firstImage.getRGB(x, y) != secondImage.getRGB(x, y)) {
                    return false;
                }
            }
        }

        return true;
    }
}

Related

  1. compareImage(BufferedImage biA, BufferedImage biB)
  2. compareImage(BufferedImage img1, BufferedImage img2)
  3. compareImage(BufferedImage img1, BufferedImage img2)
  4. compareImages(BufferedImage imageOne, BufferedImage imageTwo)
  5. compareImages(BufferedImage imgA, BufferedImage imgB)
  6. compareImages(final BufferedImage img1, final BufferedImage img2)
  7. compareImgToFile(BufferedImage img, File file)
  8. imageDifference(BufferedImage imgA, BufferedImage imgB)