File: README

package info (click to toggle)
libdmtx 0.7.2-2%2Bbuild1
  • links: PTS
  • area: main
  • in suites: wheezy
  • size: 3,676 kB
  • sloc: sh: 10,371; ansic: 10,144; cs: 596; makefile: 204; java: 161; objc: 157; python: 125; perl: 28; php: 18; ruby: 16
file content (92 lines) | stat: -rw-r--r-- 3,035 bytes parent folder | download | duplicates (2)
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
README for libdmtx-net version 0.7.2 - September 4, 2009
-----------------------------------------------------------------

libdmtx-net is a .NET wrapper for libdmtx that was originally
written by Tomas Valenta, currently maintained by Joseph Ferner
and is distributed as part of the libdmtx package.


1. libdmtx-net Installation
-----------------------------------------------------------------

1. Compile the libdmtx solution.
2. Compile the libdmtx.net solution.
3. Add a reference to Libdmtx.Net.dll in you're project. (Make
   sure you copy libdmtx.dll into the same directory as your
   binaries).


2. Dependencies
-----------------------------------------------------------------

Requires .NET Framework 2.0 (or higher) and C runtime library,
for example Microsoft Visual C++ Runtime.


3. Using
-----------------------------------------------------------------

Using is very similar to the command line utilities dmtxread
and dmtxwrite. This disallows to use the library as smart as
with C API, but saves unmanaged calls from .NET which cost
some overhead.

3.1. Decoding

LibDmtx.DecodeOptions o = new LibDmtx.DecodeOptions();
Bitmap b = new Bitmap(@"bitmap.png");
LibDmtx.DmtxDecoded[] res = LibDmtx.Decode(b, o);
for (uint i = 0; i < res.Length; i++) {
	string str = Encoding.ASCII.GetString(res[i].Data).TrimEnd('\0');
	Console.WriteLine("Code " + i + ": " + str);
}

3.2. Encoding

LibDmtx.EncodeOptions o = new LibDmtx.EncodeOptions();
byte[] dataToEncode = Encoding.ASCII.GetBytes("Hello World!");
LibDmtx.DmtxEncoded en = LibDmtx.Encode(dataToEncode, o);
pictureBox1.Image = en.bitmap;

3.3. More Information

See the source or the unit tests.


4. VB.NET example for use in ASP.NET page.
-----------------------------------------------------------------

If FileUpload1.HasFile Then
   Dim fExtension As String
   Dim fFileName As String = FileUpload1.PostedFile.FileName
   fExtension = Path.GetExtension(FileUpload1.PostedFile.FileName)
   Dim fileBytes(FileUpload1.PostedFile.InputStream.Length) As Byte
   FileUpload1.PostedFile.InputStream.Read(fileBytes, 0, fileBytes.Length)
   Dim collector As New MemoryStream(fileBytes)
   Dim gImage As Bitmap
   gImage = Bitmap.FromStream(collector)

   Dim bDecode As New Libdmtx.DecodeOptions
   bDecode.CodeType = Libdmtx.CodeType.DataMatrix
   bDecode.MaxCodes = 1
   Dim pDecode As Libdmtx.DmtxDecoded() = Libdmtx.Dmtx.Decode(gImage, bDecode)

   Dim cString As String
   cString = String.Empty
   For Each thing In pDecode
      cString = cString & Encoding.ASCII.GetString(thing.Data)
   Next
   Label1.Text = cString
   Label2.Text = pDecode.Length.ToString
End If


5. This Document
-----------------------------------------------------------------

This document is derived from the wiki page located at:

  http://libdmtx.wikidot.com/libdmtx-net-wrapper

If you find an error or have additional helpful information,
please edit the wiki directly with your updates.