Beispiel #1
0
        public virtual ImageDiff makeDiff(Screenshot expected, Screenshot actual)
        {
            var diff = new ImageDiff(expected.getImage(), actual.getImage());

            for (int i = 0; i < diff.getDiffImage().Width; i++)
            {
                for (int j = 0; j < diff.getDiffImage().Height; j++)
                {
                    if (this.insideBothImages(i, j, expected.getImage(), actual.getImage()))
                    {
                        if (this.shouldCompare(i, j, expected, actual) && !ImageTool.rgbCompare(expected.getImage().GetPixel(i, j), actual.getImage().GetPixel(i, j), this.colorDistortion))
                        {
                            diff.addDiffPoint(i, j);
                        }
                        else
                        {
                            diff.getDiffImage().SetPixel(i, j, expected.getImage().GetPixel(i, j));
                        }
                    }
                    else
                    {
                        this.setSharedPoint(i, j, expected, actual, diff);
                    }
                }
            }
            return(diff);
        }
Beispiel #2
0
        private Point getReferenceCorner(ImageDiff diff)
        {
            int x = diff.diffPoints.Min(pt => pt.X);
            int y = diff.diffPoints.Min(pt => pt.Y);

            return(new Point(x, y));
        }
Beispiel #3
0
        private ICollection <Point> deposeReference(ImageDiff diff)
        {
            Point reference = this.getReferenceCorner(diff);
            ICollection <Point> referenced = new HashSet <Point>();

            foreach (Point point in diff.diffPoints)
            {
                referenced.Add(new Point(point.X - reference.X, point.Y - reference.Y));
            }
            return(referenced);
        }
Beispiel #4
0
 private void setSharedPoint(int i, int j, Screenshot expected, Screenshot actual, ImageDiff diff)
 {
     if (Coords.ofImage(expected.getImage()).Contains(new Point(i, j)))
     {
         diff.getDiffImage().SetPixel(i, j, expected.getImage().GetPixel(i, j));
     }
     else
     {
         if (Coords.ofImage(actual.getImage()).Contains(new Point(i, j)))
         {
             diff.getDiffImage().SetPixel(i, j, actual.getImage().GetPixel(i, j));
         }
     }
 }