aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSerghei Cebotari <serghei@cebotari.ru>2024-11-07 23:32:39 +0300
committerSerghei Cebotari <serghei@cebotari.ru>2024-11-07 23:32:39 +0300
commit29bd23a52ce52fbe25dc6e738e5a47c156fb41ec (patch)
tree1f411e507fe3128c435e45486ba246b1f7e96207
parent1511dafa934738a6baff1288c95daaa087c21d5f (diff)
Convert image to base64
-rw-r--r--RhSolutions.AddIn/Tools/OcrTool.cs12
1 files changed, 8 insertions, 4 deletions
diff --git a/RhSolutions.AddIn/Tools/OcrTool.cs b/RhSolutions.AddIn/Tools/OcrTool.cs
index 965158b..a30b27c 100644
--- a/RhSolutions.AddIn/Tools/OcrTool.cs
+++ b/RhSolutions.AddIn/Tools/OcrTool.cs
@@ -2,6 +2,8 @@
using System.Runtime.Versioning;
#endif
+using System.Drawing.Imaging;
+using System.IO;
using System.Threading.Tasks;
namespace RhSolutions.Tools;
@@ -22,11 +24,13 @@ internal class OcrTool : Tool
await Task.Delay(100);
}).Wait();
- var bmp = SnippingTool.SnippingTool.Snip();
- if (bmp != null)
+ var shot = SnippingTool.SnippingTool.Snip();
+ if (shot != null)
{
- // Do something with the bitmap
- //...
+ using MemoryStream ms = new();
+ shot.Save(ms, ImageFormat.Png);
+ byte[] imageBytes = ms.ToArray();
+ string base64 = Convert.ToBase64String(imageBytes);
}
Application.Visible = true;