Example #1
0
        private Rectangle?LeagueRegionToRect(Size ogSize, LeagueRegion rect)
        {
            if (ogSize.Width == 0 || ogSize.Height == 0)
            {
                return(null);
            }
            if (rect.Left < 0 || rect.Left > 100 ||
                rect.Right < 0 || rect.Right > 100 ||
                rect.Top < 0 || rect.Top > 100 ||
                rect.Bottom < 0 || rect.Bottom > 100 ||
                rect.Right < rect.Left ||
                rect.Bottom < rect.Top)
            {
                Logger.Info("Inalid rect bounds passed to get region");
                return(null);
            }

            // Convert from the % based value to the bitmap
            Rectangle newRec = new Rectangle();

            newRec.X      = (int)(rect.Left / 100.0 * (double)ogSize.Width);
            newRec.Y      = (int)(rect.Top / 100.0 * (double)ogSize.Height);
            newRec.Height = (int)(rect.Bottom / 100.0 * (double)ogSize.Height) - newRec.Y;
            newRec.Width  = (int)(rect.Right / 100.0 * (double)ogSize.Width) - newRec.X;

            // Make sure the params are still valid.
            if (newRec.Height == 0 || newRec.Width == 0)
            {
                return(null);
            }
            return(newRec);
        }
Example #2
0
        private Bitmap BitmapGetLeagueRegion(Bitmap input, LeagueRegion cropRect)
        {
            if (input == null)
            {
                return(null);
            }
            var rect = LeagueRegionToRect(input.Size, cropRect);

            if (!rect.HasValue)
            {
                return(null);
            }
            return(GetRegion(input, rect.Value));
        }
Example #3
0
        private Tuple <string, float> GetMeDatText(Bitmap input, LeagueRegion searchRect)
        {
            if (input == null)
            {
                return(null);
            }
            var rect = LeagueRegionToRect(input.Size, searchRect);

            if (!rect.HasValue)
            {
                return(null);
            }
            return(m_ocr.GetMeDatSingleLineText(input, new Rect(rect.Value.X, rect.Value.Y, rect.Value.Width, rect.Value.Height)));
        }