예제 #1
0
        private Rectangle FindBoardBounds()
        {
            const int fromTop = 150;
            const int fromLeft = 90;
            const int width = 180;
            const int height = 360;

            int left = 0;
            int top = 0;

            {
                RollingWindow<int> lums = new RollingWindow<int>(10);
                for (int i = (int)(fromLeft * .9); i < fromTop * 1.1; i++)
                {
                    Color c = _bitmap.GetPixel(app.X + fromLeft + (width / 2), app.Y + i);

                    lums.Add((int)(c.GetBrightness() * 100));

                    if (lums.HasValue(2))
                    {
                        if (lums.Get(2) == 0 && lums.Get(1) == 16 && lums.Get(0) == 13)
                        {
                            top = i;
                            break;
                        }
                    }
                }
            }

            {
                RollingWindow<int> lums = new RollingWindow<int>(10);
                for (int i = (int)(fromLeft * .9); i < fromLeft * 1.1; i++)
                {
                    Color c = _bitmap.GetPixel(app.X + i, app.Y + fromTop + (height / 2));

                    lums.Add((int)(c.GetBrightness() * 100));

                    if (lums.HasValue(1))
                    {
                        if (lums.Get(1) == 0 && lums.Get(0) == 13)
                        {
                            left = i;
                            break;
                        }
                    }
                }
            }

            return new Rectangle(new Point(app.X + left, app.Y + top), new Size(width, height));
        }