Here you can find the source of checkImageMatch(BufferedImage img1, String imgName1, BufferedImage img2, String imgName2)
Parameter | Description |
---|---|
img1 | a parameter |
imgName1 | a parameter |
img2 | a parameter |
imgName2 | a parameter |
Parameter | Description |
---|---|
IllegalArgumentException | when image dimensions are not matching |
public static void checkImageMatch(BufferedImage img1, String imgName1, BufferedImage img2, String imgName2) throws IllegalArgumentException
//package com.java2s; //License from project: Open Source License import java.awt.image.BufferedImage; public class Main { /**/*from ww w . j a va 2s . c o m*/ * Check image dimensions are matching. * * @param img1 * @param imgName1 * @param img2 * @param imgName2 * @throws IllegalArgumentException when image dimensions are not matching */ public static void checkImageMatch(BufferedImage img1, String imgName1, BufferedImage img2, String imgName2) throws IllegalArgumentException { if ((img1.getWidth() != img2.getWidth()) || (img1.getHeight() != img2.getHeight())) { throw new IllegalArgumentException( String.format("Size mismatch (%s.{w,h}={%d,%d} and %s.{w,h}={%d,%d})", imgName1, img1.getWidth(), img1.getHeight(), imgName2, img2.getWidth(), img2.getHeight())); } // if (img1.getType() != img2.getType()) { // throw new IllegalArgumentException(String.format("Image type mismatch (%s.type=%d and %s.type=%d)", // imgName1, img1.getType(), imgName2, img2.getType())); // } } }