Beispiel #1
0
        unsafe private void Compare()
        {
            // Compare dimensions of images A and B
            if (bitmapComparatorBitmapA.Width != bitmapComparatorBitmapB.Width || bitmapComparatorBitmapA.Height != bitmapComparatorBitmapB.Height)
            {
                // We don't know how to compare Bitmaps of different sizes
                // Return info that Bitmaps dimensions are different
                bitmapComparatorResult = Result.DifferentSize;
            }
            else
            {
                int width  = bitmapComparatorBitmapA.Width;
                int height = bitmapComparatorBitmapA.Height;

                for (int y = 0; y < height; ++y)
                {
                    for (int x = 0; x < width; ++x)
                    {
                        if (bitmapComparatorBitmapA.GetPixel(x, y) != bitmapComparatorBitmapB.GetPixel(x, y))
                        {
                            // Set pixel to Cyan in difference image
                            bitmapComparatorDifference.SetPixel(x, y, true);
                        }
                    }
                }

                // Evaluate comparison result
                if (bitmapComparatorDifference.GetBitmapDifferenceMetric() > 0)
                {
                    bitmapComparatorResult = Result.DifferentColor;
                }
                else
                {
                    bitmapComparatorResult = Result.Identical;
                }
            }
        }
 public int GetBitmapDifferenceMetric()
 {
     return(bitmapDifference.GetBitmapDifferenceMetric());
 }