Exemplo n.º 1
0
        private static void ProcessLineValues(Color backgroundColor, Bitmap image, int pixelsToFeed)
        {
            var leftEdgeProcessor  = new LeftEdgePtsProcessor(image, backgroundColor);
            var rightEdgeProcessor = new RightEdgePtsProcessor(image, backgroundColor);

            var leftPts  = new Point[pixelsToFeed];
            var rightPts = new Point[pixelsToFeed];

            for (int y = image.Height - 2, ctr = 1; y > 0 && ctr <= pixelsToFeed; y--, ctr++)
            {
                leftPts[ctr - 1]  = leftEdgeProcessor.GetEdgePt(y);
                rightPts[ctr - 1] = rightEdgeProcessor.GetEdgePt(y);
            }

            var leftEdgeLine  = new LinePtsProcessor(leftPts);
            var rightEdgeLine = new LinePtsProcessor(rightPts);

            var leftMarkingColor  = Color.DarkViolet;
            var rightMarkingColor = Color.Gold;

            for (var y = 0; y < image.Height; y++)
            {
                var xLeft = leftEdgeLine.GetXValueForY(y);
                if (xLeft >= 0 && xLeft < image.Width)
                {
                    image.SetPixel(xLeft, y, leftMarkingColor);
                }
                var xRight = rightEdgeLine.GetXValueForY(y);
                if (xRight >= 0 && xRight < image.Width)
                {
                    image.SetPixel(xRight, y, rightMarkingColor);
                }
            }
        }
Exemplo n.º 2
0
        public void TestEdgePtProcessors()
        {
            var backgroundColor = TestHelper.GetBackgroundColor();
            var image           = TestHelper.GetStrippedFirstMarioImage(backgroundColor);

            var leftEdgeProcessor  = new LeftEdgePtsProcessor(image, backgroundColor);
            var rightEdgeProcessor = new RightEdgePtsProcessor(image, backgroundColor);

            var leftMarkingColor  = Color.DarkViolet;
            var rightMarkingColor = Color.Gold;

            for (var y = 0; y < image.Height; y++)
            {
                try
                {
                    var leftPt = leftEdgeProcessor.GetEdgePt(y);
                    image.SetPixel(leftPt.X, y, leftMarkingColor);
                }
                catch {}

                try
                {
                    var rightPt = rightEdgeProcessor.GetEdgePt(y);
                    image.SetPixel(rightPt.X, y, rightMarkingColor);
                }
                catch {}
            }

            image.Save(ExecutionDirInfoHelper.GetOutputDirPath() + @"\TestEdgePtProcessors.bmp");
        }