Java BufferedImage Equal equals(final BufferedImage image1, final BufferedImage image2)

Here you can find the source of equals(final BufferedImage image1, final BufferedImage image2)

Description

equals

License

Apache License

Declaration

public static boolean equals(final BufferedImage image1, final BufferedImage image2) 

Method Source Code


//package com.java2s;
/*/*from   w  ww  . ja  va2s. co m*/
 * Copyright 2012 Alexey Ivanov
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

import java.awt.image.BufferedImage;

public class Main {
    public static boolean equals(final BufferedImage image1, final BufferedImage image2) {
        final int width1 = image1.getWidth();
        final int width2 = image2.getWidth();
        if (width1 != width2) {
            return false;
        }

        final int height1 = image1.getHeight();
        final int height2 = image2.getHeight();
        if (height1 != height2) {
            return false;
        }

        for (int i = 0; i < width1; ++i) {
            for (int j = 0; j < height1; ++j) {
                if (image1.getRGB(i, j) != image2.getRGB(i, j)) {
                    return false;
                }
            }
        }
        return true;
    }
}

Related

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