-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathReadBarcode.cs
53 lines (44 loc) · 1.37 KB
/
ReadBarcode.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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using ZXing;
namespace BarcodeRecoveryCS
{
class ReadBarcode
{
public string read(Bitmap img)
{
// create a barcode reader instance
IBarcodeReader reader = new BarcodeReader();
// load a bitmap
var barcodeBitmap = img;
// detect and decode the barcode inside the bitmap
var result = reader.Decode(img);
// do something with the result
if (result != null)
{
return result.BarcodeFormat.ToString() + ", " + result.Text;
}
return "";
}
// /////////////////////////////////////////////////////////////////////////////////
public Bitmap gen128(string input)
{
BarcodeWriter toqr;
toqr = new BarcodeWriter();
toqr.Format = BarcodeFormat.CODE_128;
return toqr.Write(input);
}
// /////////////////////////////////////////////////////////////////////////////////
public Bitmap gen39(string input)
{
BarcodeWriter toqr;
toqr = new BarcodeWriter();
toqr.Format = BarcodeFormat.CODE_39;
return toqr.Write(input);
}
}
}