First time I found helpfull to push this to git
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Drawing;
|
||||
using System.IO;
|
||||
|
||||
namespace OCR_tester
|
||||
{
|
||||
public class Window
|
||||
{
|
||||
private Bitmap FullImage;
|
||||
|
||||
private Rectangle _bounds;
|
||||
public Rectangle Bounds { get => _bounds; private set => _bounds = value; }
|
||||
|
||||
public static DirectoryInfo tessDataFolder = new DirectoryInfo(@"C:\Users\Moi\Pictures\SeleniumScreens\TessData");
|
||||
|
||||
public Bitmap WindowImage
|
||||
{
|
||||
get
|
||||
{
|
||||
Bitmap sample = new Bitmap(Bounds.Width, Bounds.Height);
|
||||
Graphics g = Graphics.FromImage(sample);
|
||||
g.DrawImage(FullImage, new Rectangle(0, 0, sample.Width, sample.Height), Bounds, GraphicsUnit.Pixel);
|
||||
return sample;
|
||||
}
|
||||
}
|
||||
public Window(Bitmap fullImage, Rectangle bounds)
|
||||
{
|
||||
FullImage = fullImage;
|
||||
Bounds = bounds;
|
||||
}
|
||||
public virtual void RecoverInformations()
|
||||
{
|
||||
//Each Window type will have to implement its own way to recover the informations stored in the Window Image
|
||||
}
|
||||
public static byte[] ImageToByte(Image img)
|
||||
{
|
||||
using (var stream = new MemoryStream())
|
||||
{
|
||||
img.Save(stream, System.Drawing.Imaging.ImageFormat.Png);
|
||||
return stream.ToArray();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user