Convert image to base64
This commit is contained in:
parent
1511dafa93
commit
29bd23a52c
@ -2,6 +2,8 @@
|
|||||||
using System.Runtime.Versioning;
|
using System.Runtime.Versioning;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
using System.Drawing.Imaging;
|
||||||
|
using System.IO;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace RhSolutions.Tools;
|
namespace RhSolutions.Tools;
|
||||||
@ -22,11 +24,13 @@ internal class OcrTool : Tool
|
|||||||
await Task.Delay(100);
|
await Task.Delay(100);
|
||||||
}).Wait();
|
}).Wait();
|
||||||
|
|
||||||
var bmp = SnippingTool.SnippingTool.Snip();
|
var shot = SnippingTool.SnippingTool.Snip();
|
||||||
if (bmp != null)
|
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;
|
Application.Visible = true;
|
||||||
|
Loading…
Reference in New Issue
Block a user