static void Main(string[] args) { //Run(args); Bitmap tmp = new Bitmap("small.bmp"); Bitmap res = recolor(tmp); res.Save("small2_bw.bmp"); var ocr = new TextExtractor("rus"); string text = ocr.GetTextFromBitmapAsync(tmp).Result; Console.WriteLine(text); }
static void Run(string[] args) { Thread.Sleep(1000); var ocr = new TextExtractor("rus"); for (int id = 0; ; ++id, Thread.Sleep(1000)) { try { Nullable <IntPtr> leagueHandle = FetchLeagueHandle(); if (!leagueHandle.HasValue) { Console.WriteLine("League window not detected."); continue; } Bitmap orig = Direct3DCapture.CaptureWindow(leagueHandle.Value); if (orig == null) { continue; } Bitmap processed = orig.Clone(new Rectangle(0, 0, orig.Width, orig.Height), PixelFormat.Format32bppArgb); processed.Save($"processed{id}.bmp"); continue; orig = null; //using (FileStream compressedFileStream = File.Create("processed.bmp.gz")) { // using (GZipStream compressionStream = new GZipStream(compressedFileStream, CompressionLevel.Optimal)) { // processed.Save(compressionStream, System.Drawing.Imaging.ImageFormat.Bmp); // } //} //processed.Save($"processed{id}.bmp"); int cachedId = id; ocr.GetTextFromBitmapAsync( processed, new Rect(0, 0, processed.Width, processed.Height) ).ContinueWith(async t => { string text = await t; File.AppendAllText($"text{cachedId}", text); }); } catch (Exception e) { } } }