Class StrictImageComparator

  • All Implemented Interfaces:
    ImageComparator
    Direct Known Subclasses:
    ColorImageComparator

    public class StrictImageComparator
    extends java.lang.Object
    implements ImageComparator
    Compares two images strictly (i.e. all the pixel colors should match).
    Author:
    Alexandre Iline (alexandre.iline@sun.com)
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean compare​(java.awt.image.BufferedImage image1, java.awt.image.BufferedImage image2)
      Checks images sizes and pixels.
      protected boolean compareColors​(int rgb1, int rgb2)
      Could be used to override the way of comparing colors.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • StrictImageComparator

        public StrictImageComparator()
    • Method Detail

      • compare

        public boolean compare​(java.awt.image.BufferedImage image1,
                               java.awt.image.BufferedImage image2)
        Checks images sizes and pixels. Compares one pixel after another untill one will be different.
        Specified by:
        compare in interface ImageComparator
        Parameters:
        image1 - an image to compare.
        image2 - an image to compare.
        Returns:
        True if all the pixels match, false otherwise.
      • compareColors

        protected boolean compareColors​(int rgb1,
                                        int rgb2)
        Could be used to override the way of comparing colors.
        Parameters:
        rgb1 - a color to compare.
        rgb2 - a color to compare.
        Returns:
        true if colors are equal.