| |
 |
Read Linear, 2D and Postal Barcodes |
 |
This demo reads the image and recognizes the barcode from it.
You can freely upload your image to our website and scan for barcodes.
Different symbology types are available to choose from. You can check all or any specific symbology.
Popular image formats like bmp, jpeg, jpg, gif, png etc may be uploaded in this demo.
For more details please see the following topics:
| ASP.NET |
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
|
<%@ page language="C#" masterpagefile="~/tpl/Demo.Master" autoeventwireup="true" inherits="NewOnline.Recognition, App_Web_kgc_wyso" title="Read Linear, 2D and Postal Barcodes" %>
<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server">
<table width="90%" align="center" cellspacing="0" cellpadding="0" border="0">
<tr>
<td width="19"><img src="/Common/images/heading_lft.jpg" alt="" width="19" height="41" /></td>
<td width="100%" class="demos-heading-bg"><h2 class="demos-heading-bg" style="text-align: left"> Read Linear, 2D and Postal Barcodes</h2></td>
<td width="19"><img src="/Common/images/heading_rt.jpg" alt="" width="19" height="41" /></td>
</tr>
</table>
<br />
<p class="componentDescriptionTxt" style="text-align: left">
This demo reads the image and recognizes the barcode from it.
You can freely upload your image to our website and scan for barcodes.
Different symbology types are available to choose from. You can check all or any specific symbology.
Popular image formats like bmp, jpeg, jpg, gif, png etc may be uploaded in this demo.
<br><br>For more details please see the following topics:
</p>
<ul>
<li style="text-align: left">
<a href="http://www.aspose.com/documentation/.net-components/aspose.barcode-for-.net/introducing-barcode-recognition.html">BarCode Recognition with Aspose.BarCode</a>
</li>
<li style="text-align: left">
<a href="http://www.aspose.com/documentation/.net-components/aspose.barcode-for-.net/scan-result.html">Getting the Result After BarCode Recognition</a>
</li>
</ul>
<table class="genericTable">
<tr>
<td style="text-align: left"><table>
<tr>
<td align="left">
Choose the symbologies
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td style="text-align: left">
<asp:Button ID="Button3" runat="server" Text="Select All Symbologies"
onclick="Button3_Click" />
<asp:Button ID="Button4" runat="server" Text="Select None"
onclick="Button4_Click" />
</td>
</tr>
<tr>
<td style="text-align: left">
<asp:CheckBoxList ID="chSymbology" runat="server" CellPadding="3"
CellSpacing="3" RepeatColumns="5" RepeatDirection="Horizontal">
</asp:CheckBoxList>
</td>
</tr>
<tr>
<td style="text-align: left">
Upload image files to scan for barcodes. Please upload a file of size less than
1 MB</td>
</tr>
<tr>
<td style="text-align: left">
<input id="file1" runat="server" name="file1" size="34" style="width: 320px; height: 22px"
type="file" />
<asp:Button ID="Button1" runat="server" Height="22px" OnClick="Button1_Click" Text="Upload"
Width="80px" />
<asp:Button ID="Button2" runat="server" Height="22px" OnClick="Button2_Click" Text="Scan image"
Width="120px" /></td>
</tr>
<tr>
<td style="text-align: left">
<asp:Label
ID="Label1" runat="server" Font-Bold="True" Font-Names="Verdana" ForeColor="DarkGreen">Ready.</asp:Label>
<br />
<asp:Image ID="Image1" runat="server" ImageUrl="http://www.aspose.com/products/aspose.barcode/images/recognition/logo.jpg" />
<br />
</td>
</tr>
<tr>
<td>
</td>
</tr>
<tr>
<td style="text-align: left">
</td>
</tr>
</table>
</asp:Content>
|
| C# |
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
|
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Drawing;
using System.IO;
using Aspose.BarCodeRecognition;
namespace NewOnline
{
public partial class Recognition : System.Web.UI.Page
{
public string userImageUrl = "";
protected void Page_Load(object sender, EventArgs e)
{
if (Page.IsPostBack == false)
{
ArrayList arrSymbologies = Utility.GetBarcodeReadTypes();
chSymbology.DataSource = arrSymbologies;
chSymbology.DataBind();
}
}
protected void Button1_Click(object sender, EventArgs e)
{
if (this.file1.PostedFile != null)
{
HttpPostedFile postedFile = this.file1.PostedFile;
int contentLength = postedFile.ContentLength;
if (contentLength > 1024*1024)
{
this.Label1.Text = "Error: Please upload a file of size less than 1 MB";
this.Label1.ForeColor = Color.Red;
}
else if (contentLength > 0)
{
byte[] buffer = new byte[contentLength];
postedFile.InputStream.Read(buffer, 0, contentLength);
base.Session["userfilename"] = "../userpic/" + Guid.NewGuid().ToString() + postedFile.FileName.Substring(postedFile.FileName.LastIndexOf('.'));
string path = (string)base.Session["userfilename"];
FileStream stream = new FileStream(base.Server.MapPath(path), FileMode.Create);
stream.Write(buffer, 0, buffer.Length);
stream.Close();
this.Image1.ImageUrl = path;
this.Image1.ToolTip = "this is a picture uploaded by user";
this.Label1.Text = "picture upload complete.";
this.Label1.ForeColor = Color.DarkGreen;
}
else
{
this.Label1.Text = "File length is zero";
this.Label1.ForeColor = Color.Red;
}
}
else
{
this.Label1.Text = "Please select an image file to upload";
this.Label1.ForeColor = Color.Red;
}
}
protected void Button2_Click(object sender, EventArgs e)
{
if (base.Session["userfilename"] != null)
{
string str = base.Session["userfilename"] as string;
str = str.Remove(0, 2);
this.userImageUrl = "http://www.aspose.com/products/aspose.barcode" + str;
try
{
BarCodeReadType readType = BarCodeReadType.Empty;
foreach (ListItem item in chSymbology.Items)
{
if (item.Selected == true)
{
readType |= BarCodeReadType.FromString(item.Value);
}
}
BarCodeReader reader = new BarCodeReader(base.Server.MapPath((string)base.Session["userfilename"]), readType);
bool bRecognized = false;
this.Label1.Text = "";
while (reader.Read() == true)
{
this.Label1.Text += "CodeText: " + reader.GetCodeText() +
"<br> BarCode Symbology: " + reader.GetReadType().ToString() + "<br><hr/>";
bRecognized = true;
}
if (bRecognized == false)
{
this.Label1.Text = "Barcode not found, please try different symbologies";
}
}
catch (Exception exception)
{
this.Label1.Text = exception.Message;
this.Label1.ForeColor = Color.Red;
}
}
else
{
this.Label1.Text = "image not found";
this.Label1.ForeColor = Color.Red;
}
}
protected void Button3_Click(object sender, EventArgs e)
{
// check all symbologies
foreach (ListItem item in chSymbology.Items)
{
item.Selected = true;
}
}
protected void Button4_Click(object sender, EventArgs e)
{
// un-check all symbologies
foreach (ListItem item in chSymbology.Items)
{
item.Selected = false;
}
}
}
}
|
|
|
|