private static int ScanLevel(ref bool ascended) { int level = -1; var xRef = 1280.0; var yRef = 720.0; if (Navigation.GetAspectRatio() == new Size(8, 5)) { yRef = 800.0; } Rectangle region = new RECT( Left: (int)(960 / xRef * Navigation.GetWidth()), Top: (int)(135 / yRef * Navigation.GetHeight()), Right: (int)(1125 / xRef * Navigation.GetWidth()), Bottom: (int)(163 / yRef * Navigation.GetHeight())); do { Bitmap bm = Navigation.CaptureRegion(region); bm = Scraper.ResizeImage(bm, bm.Width * 2, bm.Height * 2); Bitmap n = Scraper.ConvertToGrayscale(bm); Scraper.SetInvert(ref n); Scraper.SetContrast(30.0, ref bm); string text = Scraper.AnalyzeText(n).Trim(); text = Regex.Replace(text, @"(?![0-9/]).", string.Empty); if (text.Contains("/")) { var values = text.Split('/'); if (int.TryParse(values[0], out level) && int.TryParse(values[1], out int maxLevel)) { maxLevel = (int)Math.Round(maxLevel / 10.0, MidpointRounding.AwayFromZero) * 10; ascended = 20 <= level && level < maxLevel; UserInterface.SetCharacter_Level(bm, level, maxLevel); n.Dispose(); bm.Dispose(); return(level); } n.Dispose(); bm.Dispose(); } Navigation.SystemRandomWait(Navigation.Speed.Normal); } while (level == -1); return(-1); }