You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

67 lines
1.6 KiB
C#

2 years ago
using System;
using System.Windows;
using System.Windows.Input;
using System.Drawing;
using System.IO;
using System.Drawing.Imaging;
using PINBlog;
2 years ago
namespace ScreenShotOCR
{
public delegate Bitmap EventHandlerGrab();
2 years ago
/// <summary>
/// MainWindow.xaml에 대한 상호 작용 논리
/// </summary>
public partial class MainWindow : Window
{
CaptureWindow m_cw = new CaptureWindow();
2 years ago
public MainWindow()
{
InitializeComponent();
}
private void Window_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
this.DragMove();
}
private void CaptureBtn_Click(object sender, RoutedEventArgs e)
{
m_cw.Show();
this.Topmost = true;
}
private void Close_Click(object sender, RoutedEventArgs e)
{
m_cw.Close();
this.Close();
}
private void OCRBtn_Click(object sender, RoutedEventArgs e)
{
Bitmap crop = m_cw.m_handlerGrab();
Tesseract(crop);
}
private bool Tesseract(Image image)
{
try
{
MemoryStream stream = new MemoryStream();
image.Save(stream, ImageFormat.Png);
var tesseract = new Tesseract();
var result = tesseract.GetText(stream);
textblock.Text = result;
return true;
}
catch (Exception ex)
{
return false;
}
}
2 years ago
}
}