bool is_in_begin_picture() { var c = ImageCompare.CalculateCurrentAverageColor(); App.MW.Log += c.ToString() + "\n"; return(begin_color.Contains(c)); }
public void TestMethod1() { var imagePath1 = "C:\\temp\\VideoControl\\Img_19.03.17_12.13.56.jpg"; var imagePath2 = "C:\\temp\\VideoControl\\Img_19.03.17_12.16.54.jpg"; var comparer = new ImageCompare(imagePath1, imagePath2); comparer.Compare(); }
bool is_in_ready_picture() { var c = ImageCompare.CalculateCurrentAverageColor(); //App.MW.Log += c.ToString()+ "ready\n"; return(ready_color.Contains(c)); }
void get_color() { int x = (int)readyPoint.X; int y = (int)readyPoint.Y; int r = 0, g = 0, b = 0; int n = 0; App.MW.textBox.Text += "开始计算:"; double zoom = DisplaySettings.Scaling; var c = ImageCompare.CalculateCurrentAverageColor(); r = c.R; g = c.G; b = c.B; App.MW.textBox.Text += "R" + r + ",G" + g + ",B" + b + "\n"; }
public void CompareScreenshot(string filename, By byObject = null) { bool DAILY_REPORT_ENABLED = Convert.ToBoolean(ConfigurationManager.AppSettings["DAILY_REPORT_ENABLED"]); bool UI_TEST_ENABLED = Convert.ToBoolean(ConfigurationManager.AppSettings["UI_TEST_ENABLED"]); int threshold = Convert.ToInt32(ConfigurationManager.AppSettings["IMAGE_COMPARE_THRESHOLD"]); string strScreenshotFileName = filename + ".png"; string strBaseLineImage = Utils.BaselinePath + Utils.separator + strScreenshotFileName; string strActualImage = Utils.ActualScreenshotPath + Utils.separator + strScreenshotFileName; string strDiffImage = Utils.DiffScreenshotPath + Utils.separator + strScreenshotFileName; try { if (!(DAILY_REPORT_ENABLED && UI_TEST_ENABLED)) { throw new Exception("Enable both option DAILY_REPORT_ENABLED and UI_TEST_ENABLED to active the UI testing mode"); } WaitForFullPageLoaded(); if (!File.Exists(strBaseLineImage)) { if (byObject == null) { CaptureScreenshot(Utils.BaselinePath, filename); } else { CaptureScreenshot(Utils.BaselinePath, filename, byObject); } NLogger.Info("The baseline screenshot of [" + filename + "] not exist, creating it"); HtmlReporter.Pass("The baseline screenshot of [" + filename + "] not exist, creating it"); } else { if (byObject == null) { CaptureScreenshot(Utils.ActualScreenshotPath, filename); } else { CaptureScreenshot(Utils.ActualScreenshotPath, filename, byObject); } Bitmap diffImage = ImageCompare.DiffImage(strActualImage, strBaseLineImage, threshold); if (diffImage == null) { NLogger.Info("The actual screenshot of [" + filename + "] matches with the baseline"); HtmlReporter.Pass("The actual screenshot of [" + filename + "] matches with the baseline", strActualImage); } else { diffImage.Save(strDiffImage); //NLogger.Error("The actual screenshot of [" + filename + "] not matches with the baseline"); HtmlReporter.Fail("The actual screenshot of [" + filename + "] not matches with the baseline", strDiffImage); throw new Exception("The actual screenshot of [" + filename + "] not matches with the baseline"); } } } catch (Exception ex) { string message = string.Format("There is an error when comparing the screenshot of page [{0}]", filename); //HtmlReporter.Fail(message, ex); throw new ErrorHandler(message, ex); } }
static void Main(string[] args) { Console.WriteLine("Hello World!"); ImageCompare.CompareImages(); }