Class StrictImageComparator

  • All Implemented Interfaces:
    ImageComparator
    Direct Known Subclasses:
    ColorImageComparator

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

      • StrictImageComparator

        public StrictImageComparator()
    • Method Detail

      • compare

        public boolean compare​(BufferedImage image1,
                               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.