I just dont want to loose all of this even tho it does not work
This commit is contained in:
+40
-2
@@ -4,6 +4,7 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Drawing;
|
||||
using System.IO;
|
||||
|
||||
namespace OCR_Decode
|
||||
{
|
||||
@@ -13,8 +14,11 @@ namespace OCR_Decode
|
||||
private Bitmap _image;
|
||||
private string _name;
|
||||
public Rectangle Bounds { get => _bounds; private set => _bounds = value; }
|
||||
public Bitmap Image { get => _image; private set => _image = value; }
|
||||
public string Name { get => _name; set => _name = value; }
|
||||
public Bitmap Image { get => _image; set => _image = value; }
|
||||
public string Name { get => _name; protected set => _name = value; }
|
||||
|
||||
public static DirectoryInfo TESS_DATA_FOLDER = new DirectoryInfo(@"C:\Users\Moi\Pictures\SeleniumScreens\TessData");
|
||||
|
||||
public Bitmap WindowImage
|
||||
{
|
||||
get
|
||||
@@ -30,5 +34,39 @@ namespace OCR_Decode
|
||||
Image = image;
|
||||
Bounds = bounds;
|
||||
}
|
||||
public virtual Object DecodePng()
|
||||
{
|
||||
return " ";
|
||||
}
|
||||
public static byte[] ImageToByte(Image img)
|
||||
{
|
||||
using (var stream = new MemoryStream())
|
||||
{
|
||||
img.Save(stream, System.Drawing.Imaging.ImageFormat.Png);
|
||||
return stream.ToArray();
|
||||
}
|
||||
}
|
||||
public static Bitmap ConvertToBlackAndWhite(Bitmap inputBmp, int Treshold = 165)
|
||||
{
|
||||
Bitmap result = new Bitmap(inputBmp.Width, inputBmp.Height);
|
||||
|
||||
for (int y = 0; y < inputBmp.Height; y++)
|
||||
{
|
||||
for (int x = 0; x < inputBmp.Width; x++)
|
||||
{
|
||||
Color pixelColor = inputBmp.GetPixel(x, y);
|
||||
if (pixelColor.R <= Treshold && pixelColor.G <= Treshold && pixelColor.B <= Treshold)
|
||||
{
|
||||
pixelColor = Color.FromArgb(0, 0, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
pixelColor = Color.FromArgb(255, 255, 255);
|
||||
}
|
||||
result.SetPixel(x, y, pixelColor);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user