void IVisualAnalyzer.Compare()
        {
            MagickImage magickBaseImg   = new MagickImage(mAct.baseImage);
            MagickImage magickTargetImg = new MagickImage(mAct.targetImage);

            var diffImg = new MagickImage();

            double percentageDifference;

            // TODO: add combo with list of options for user to choose the Error Matic and Cahnnels
            ActInputValue AIV = mAct.GetOrCreateInputParam(ActVisualTesting.Fields.ErrorMetric);

            //TODO: fix me - removed hard code
            //caused build problem on build machine so temp fix for now
            ErrorMetric EM = ErrorMetric.Fuzz;

            percentageDifference = magickBaseImg.Compare(magickTargetImg, EM, diffImg, Channels.Red);
            percentageDifference = percentageDifference * 100;
            percentageDifference = Math.Round(percentageDifference, 2);

            Bitmap ImgToSave = diffImg.ToBitmap();

            mAct.CompareResult = ImgToSave;

            mAct.AddOrUpdateReturnParamActual("Percentage Difference", percentageDifference + "");

            mAct.AddScreenShot(ImgToSave, "Compare Result");
        }
Exemple #2
0
        void IVisualAnalyzer.Compare()
        {
            //TODO: use interface on the driver to get elements
            if (mDriver is IVisualTestingDriver)
            {
                IVisualTestingDriver d = (IVisualTestingDriver)mDriver;

                string             filename = mAct.GetFullFilePath(mAct.BaselineInfoFile);
                VisualElementsInfo VE1      = VisualElementsInfo.Load(filename);
                VE1.Bitmap = mAct.baseImage;

                VisualElementsInfo VE2 = d.GetVisualElementsInfo();
                VE1.Compare(VE2);
                IEnumerable <VisualElement> listwithnomatch = from x in VE1.Elements where x.Text != "" && x.MatchingElement == null select x;

                // Create compare bitmap for VE1
                Bitmap bmp = new Bitmap(VE1.Bitmap);
                // mark element with no match
                foreach (VisualElement VE in listwithnomatch)
                {
                    using (Graphics gr = Graphics.FromImage(bmp))
                    {
                        gr.SmoothingMode = SmoothingMode.AntiAlias;

                        //TODO: check the -3 or + 6 will not go out of bitmap
                        Rectangle rect = new Rectangle(VE.X - 3, VE.Y - 3, VE.Width + 6, VE.Height + 6);

                        gr.FillRectangle(Brushes.Transparent, rect);
                        using (Pen thick_pen = new Pen(Color.HotPink, 2))
                        {
                            gr.DrawRectangle(thick_pen, rect);
                        }
                    }
                }

                mAct.CompareResult = bmp;

                // Add output of mismatch
                mAct.AddOrUpdateReturnParamActual("Mismatch elements in target", listwithnomatch.Count() + "");

                //TODO: if output each mismatch then do output


                mAct.AddScreenShot(bmp, "Compare Result");

                //TODO: add small bitmap of mismatch elem
            }
        }