예제 #1
0
        public async Task RelativePanelXamlTest()
        {
            await UIHelpers.RunUITest(async (container, info) =>
            {
                var panel = new TestPages.RelativePanel1()
                {
                    Width = 600, Height = 400
                };
                container.Content = panel;
                var bitmap        = await UIHelpers.RenderAsync(panel, info.ScaleFactor);
                var redblobs      = ImageAnalysis.FindConnectedPixels(bitmap, info.ScaleFactor, System.Drawing.Color.Red);
                var blueblobs     = ImageAnalysis.FindConnectedPixels(bitmap, info.ScaleFactor, System.Drawing.Color.Blue);
                var greenblobs    = ImageAnalysis.FindConnectedPixels(bitmap, info.ScaleFactor, System.Drawing.Color.Green);
                var cyanblobs     = ImageAnalysis.FindConnectedPixels(bitmap, info.ScaleFactor, System.Drawing.Color.Cyan);
                var orangeblobs   = ImageAnalysis.FindConnectedPixels(bitmap, info.ScaleFactor, System.Drawing.Color.Orange);
                var purpleblobs   = ImageAnalysis.FindConnectedPixels(bitmap, info.ScaleFactor, System.Drawing.Color.Purple);
                var yellowblobs   = ImageAnalysis.FindConnectedPixels(bitmap, info.ScaleFactor, System.Drawing.Color.Yellow);
                var textblobs     = ImageAnalysis.FindConnectedPixels(bitmap, info.ScaleFactor, System.Drawing.Color.CornflowerBlue);
                Assert.AreEqual(1, redblobs.Count, "Red blob count");
                Assert.AreEqual(1, blueblobs.Count, "Blue blob count");
                Assert.AreEqual(1, greenblobs.Count, "Green blob count");
                Assert.AreEqual(1, cyanblobs.Count, "Cyan blob count");
                Assert.AreEqual(1, orangeblobs.Count, "Orange blob count");
                Assert.AreEqual(1, purpleblobs.Count, "Purple blob count");
                Assert.AreEqual(1, yellowblobs.Count, "Yellow blob count");
                Assert.IsTrue(textblobs.Count > 1, "Text blob count");
                var textblob = textblobs.Union(); //Generate bounding box of all text blobs
                Assert.IsTrue(textblob.MaxColumn < yellowblobs[0].MinColumn, "Text left of yellow");
                Assert.IsTrue(textblob.MinColumn < yellowblobs[0].MinRow, "Text below yellow top");

                Assert.AreEqual(0, redblobs[0].MinRow, "Red top side");
                Assert.AreEqual(0, redblobs[0].MinColumn, "Red left side");
                Assert.AreEqual(100, redblobs[0].Width, "Red width", 1);
                Assert.AreEqual(100, redblobs[0].Height, "Red height", 1);
            });
        }
예제 #2
0
        public static async Task <IList <Blob> > FindConnectedPixelsAsync(FrameworkElement element, double scaleFactor, Func <Color, bool> includePixelFunction)
        {
            var bitmap = await UIHelpers.RenderAsync(element, scaleFactor);

            return(FindConnectedPixels(bitmap, scaleFactor, includePixelFunction));
        }