public static void OpenOCR(TaskSettings taskSettings = null) { if (taskSettings == null) { taskSettings = TaskSettings.GetDefaultTaskSettings(); } using (Image img = RegionCaptureTasks.GetRegionImage(taskSettings.CaptureSettings.SurfaceOptions)) { if (img != null) { using (Stream stream = SaveImageAsStream(img, EImageFormat.PNG)) { if (stream != null) { using (OCRSpaceForm form = new OCRSpaceForm(stream, "ShareX.png")) { form.Language = Program.Settings.OCRLanguage; form.ShowDialog(); Program.Settings.OCRLanguage = form.Language; } } } } } }
private void DecodeFromScreen() { try { if (Visible) { Hide(); Thread.Sleep(250); } TaskSettings taskSettings = TaskSettings.GetDefaultTaskSettings(); using (Bitmap bmp = RegionCaptureTasks.GetRegionImage(taskSettings.CaptureSettings.SurfaceOptions)) { if (bmp != null) { DecodeImage(bmp); } } } finally { this.ForceActivate(); } }
private async void btnSelectRegion_Click(object sender, EventArgs e) { FormWindowState previousState = WindowState; WindowState = FormWindowState.Minimized; await Task.Delay(250); Bitmap regionImage = RegionCaptureTasks.GetRegionImage(new RegionCaptureOptions()); WindowState = previousState; if (regionImage != null) { bmpSource?.Dispose(); bmpSource = regionImage; await Task.Delay(250); await OCR(bmpSource); } }
private void btnDecodeFromScreen_Click(object sender, EventArgs e) { try { Hide(); Thread.Sleep(250); using (Image img = RegionCaptureTasks.GetRegionImage(null)) { if (img != null) { DecodeImage((Bitmap)img); } } } finally { this.ForceActivate(); } }
private void btnDecodeFromScreen_Click(object sender, EventArgs e) { try { Hide(); Thread.Sleep(250); TaskSettings taskSettings = TaskSettings.GetDefaultTaskSettings(); using (Bitmap bmp = RegionCaptureTasks.GetRegionImage(taskSettings.CaptureSettings.SurfaceOptions)) { if (bmp != null) { DecodeImage(bmp); } } } finally { this.ForceActivate(); } }