Ejemplo n.º 1
0
        /// <summary>
        /// Compare Images.
        /// </summary>
        /// <param name="img1">Image 1.</param>
        /// <param name="img2">Image 2.</param>
        /// <param name="imgEqualPercentage">Image equal value in percentage. 0.0% == completely unequal. 100.0% == completely equal.</param>
        /// <param name="imgDiff">Image with red pixel where <paramref name="img1"/> and <paramref name="img2"/> are unequal.</param>
        /// <returns>If images are completely equal: true; otherwise: false</returns>
        protected virtual bool ImagesAreEqual(INormalImage img1, INormalImage img2, out float imgEqualPercentage, out INormalImage imgDiff)
        {
            throw new NotImplementedException();
            //// Defaults.
            //var diffColor = Color.Red;

            //// Reset.
            //imgEqualPercentage = 0;
            //imgDiff = null;

            //// Requirements.
            //if (img1 == null)
            //    return false;
            //if (img2 == null)
            //    return false;
            //if (img1.Size.Width < 1 && img1.Height < 1)
            //    return false;
            //if (!img1.Size.Equals(img2.Size))
            //    return false;

            //// Compare bitmaps.
            //imgDiff = new Bitmap(img1.Size.Width, img1.Size.Height);
            //int diffPixelCount = 0;
            //for (int i = 0; i < img1.Width; ++i)
            //{
            //    for (int j = 0; j < img1.Height; ++j)
            //    {
            //        Color color;
            //        if ((color = img1.GetPixel(i, j)) == img2.GetPixel(i, j))
            //        {
            //            imgDiff.SetPixel(i, j, color);
            //        }
            //        else
            //        {
            //            ++diffPixelCount;
            //            imgDiff.SetPixel(i, j, diffColor);
            //        }
            //    }
            //}

            //// Calculate percentage.
            //int totalPixelCount = img1.Width * img1.Height;
            //var imgDiffFactor = ((float)diffPixelCount / totalPixelCount);
            //imgEqualPercentage = imgDiffFactor * 100;

            //return (imgDiffFactor == 1f);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Compare Images.
        /// </summary>
        /// <param name="img1">Image 1.</param>
        /// <param name="img2">Image 2.</param>
        /// <param name="imgEqualPercentage">Image equal value in percentage. 0.0% == completely unequal. 100.0% == completely equal.</param>
        /// <returns>If images are completely equal: true; otherwise: false</returns>
        protected virtual bool ImagesAreEqual(INormalImage img1, INormalImage img2, out float imgEqualPercentage)
        {
            INormalImage imgDiff; // To ignore.

            return(ImagesAreEqual(img1, img2, out imgEqualPercentage, out imgDiff));
        }