Java BufferedImage Equal bufferedImagesEqual(final BufferedImage img1, final BufferedImage img2)

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

Description

buffered Images Equal

License

Open Source License

Declaration

private static boolean bufferedImagesEqual(final BufferedImage img1, final BufferedImage img2) 

Method Source Code


//package com.java2s;
/*  Copyright (C) 2014 Reinventing Geospatial, Inc
 *
 *  This program 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 3 of the License, or
 *  (at your option) any later version./*from  w  ww  . j a v a  2s  . c  om*/
 *
 *  This program 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 this program.  If not, see <http://www.gnu.org/licenses/>,
 *  or write to the Free Software Foundation, Inc., 59 Temple Place -
 *  Suite 330, Boston, MA 02111-1307, USA.
 */

import java.awt.image.BufferedImage;

public class Main {
    private static boolean bufferedImagesEqual(final BufferedImage img1, final BufferedImage img2) {
        if (img1.getWidth() != img2.getWidth() || img1.getHeight() != img2.getHeight()) {
            return false;
        }

        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;
                }
            }
        }

        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)