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#
67 lines
1.6 KiB
C#
using System;
|
|
using System.Windows;
|
|
using System.Windows.Input;
|
|
using System.Drawing;
|
|
using System.IO;
|
|
using System.Drawing.Imaging;
|
|
using PINBlog;
|
|
|
|
namespace ScreenShotOCR
|
|
{
|
|
public delegate Bitmap EventHandlerGrab();
|
|
/// <summary>
|
|
/// MainWindow.xaml에 대한 상호 작용 논리
|
|
/// </summary>
|
|
public partial class MainWindow : Window
|
|
{
|
|
CaptureWindow m_cw = new CaptureWindow();
|
|
|
|
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;
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
}
|