Java BufferedImage Operation checkImageMatch(BufferedImage img1, String imgName1, BufferedImage img2, String imgName2)

Here you can find the source of checkImageMatch(BufferedImage img1, String imgName1, BufferedImage img2, String imgName2)

Description

Check image dimensions are matching.

License

Open Source License

Parameter

Parameter Description
img1 a parameter
imgName1 a parameter
img2 a parameter
imgName2 a parameter

Exception

Parameter Description
IllegalArgumentException when image dimensions are not matching

Declaration

public static void checkImageMatch(BufferedImage img1, String imgName1, BufferedImage img2, String imgName2)
        throws IllegalArgumentException 

Method Source Code


//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()));
        //        }
    }
}

Related

  1. buildSectors(BufferedImage a, int sqrtSectors)
  2. cascadeHorizontal(final BufferedImage... images)
  3. changeContrast(BufferedImage img, float amount)
  4. changeImageToArray(BufferedImage bufferedImage)
  5. checkIfManyColors(BufferedImage image)
  6. checkImageType(BufferedImage img, String name)
  7. checkRadius(final BufferedImage src, final int x, final int y, final int opaqueLimit, final int radius)
  8. chunk(BufferedImage image)
  9. circularize(BufferedImage image)