Ejemplo n.º 1
0
        private static List <Rect> GetBelowHorizontalFlagRect(Rect belowFlgRect, Bitmap image)
        {
            List <Rect> result = new List <Rect>();
            Rect        rect;

            bool[,] marker = new bool[image.Width, image.Height];
            int   y            = belowFlgRect.GetCenterPoint().y;
            int   x            = belowFlgRect.GetCenterPoint().x;
            int   totalFlgRect = Constant.BELOW_HORIZONTAL_FLAG_RECT;
            Point p;

            while (result.Count < totalFlgRect)
            {
                p = new Point(x, y);
                if (!p.IsValidPoint())
                {
                    throw new Exception(ErrorUtils.getError(ErrorUtils.CAN_NOT_GET_ENOUGH_HORIZONTAL_FLAG_RECT, "Can not get enough horizontal flag rect!!"));
                }
                if (!marker[x, y] && CommonImageProcessing.IsBlackColor(new Point(x, y), image))
                {
                    rect = CommonImageProcessing.ExpandTheRectBlackPixel(new Point(x, y), image, ref marker);
                    if (rect == null)
                    {
                        throw new Exception(ErrorUtils.getError(ErrorUtils.CAN_NOT_GET_ENOUGH_HORIZONTAL_FLAG_RECT, "Can not get enough horizontal flag rect!!"));
                    }
                    if (CommonImageProcessing.IsFlagRectangle(rect))
                    {
                        result.Add(rect);
                    }
                }
                x--;
            }
            return(result);
        }
Ejemplo n.º 2
0
        private static List <Rect> GetVerticalFlagRect(Rect aboveFlgRect, Bitmap image)
        {
            List <Rect> result = new List <Rect>();
            Rect        rect;

            bool[,] marker = new bool[image.Width, image.Height];
            int   y            = aboveFlgRect.GetCenterPoint().y;
            int   x            = aboveFlgRect.GetCenterPoint().x;
            int   totalFlgRect = TemplateUtils.GetNumberOfVerticalFLagRect(Globals.currentTemplate);
            Point p;

            while (result.Count < totalFlgRect)
            {
                p = new Point(x, y);
                if (!p.IsValidPoint())
                {
                    throw new Exception(ErrorUtils.getError(ErrorUtils.CAN_NOT_GET_ENOUGH_VERTICAL_FLAG_RECT, "Can not get enough vertical flag rect!!"));
                }
                if (!marker[x, y] && CommonImageProcessing.IsBlackColor(new Point(x, y), image))
                {
                    rect = CommonImageProcessing.ExpandTheRectBlackPixel(new Point(x, y), image, ref marker);
                    if (rect == null)
                    {
                        throw new Exception(ErrorUtils.getError(ErrorUtils.CAN_NOT_GET_ENOUGH_VERTICAL_FLAG_RECT, "Can not get enough vertical flag rect!!"));
                    }
                    if (CommonImageProcessing.IsFlagRectangle(rect))
                    {
                        result.Add(rect);
                    }
                }
                y++;
            }
            return(result);
        }