-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMLA.cs
37 lines (35 loc) · 1022 Bytes
/
MLA.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
using ZXing;
using ZXing.Common;
using ZXing.QrCode;
namespace TheTalosCompanion
{
internal class MLA
{
public static string DecodeQrcode(Image image)
{
var source = new BitmapLuminanceSource(new Bitmap(image));
BinaryBitmap bitmap = new BinaryBitmap(new HybridBinarizer(source));
Result result = new QRCodeReader().decode(bitmap);
if (result != null)
{
return result.Text;
}
else
{
return "Could not decode qrcode!";
}
}
public static string DecodeHex(string hex)
{
try
{
List<string> charList = hex.Replace(" ", "").Chunk(2).Select(x => new string(x)).ToList();
return String.Join("", charList.Select(hex => Convert.ToChar(Convert.ToUInt32(hex, 16))));
}
catch
{
return "Invalid input";
}
}
}
}