2012-04-10 124 views
6

我需要库从C#项目(windows窗体)上的图像中读取二维条形码(datamatrix),我使用其他sdk's来试用它,但该sdk不是免费的。是否有任何免费sdk供阅读2d条码图像?从图像中读取二维条码

+1

http://www.codeproject.com/Articles/10162/Creating-EAN-13-Barcodes-with-C,http://community.bartdesmet.net/ blogs/bart/archive/2006/09/18/4432.aspx,http://www.idautomation.com/formscontrols/free/,...你试图遵循哪些规范? – 2012-04-10 07:31:54

+0

我需要再次从图像 – 2012-04-10 08:38:57

+0

中读取2D数据矩阵:哪个规格? – 2012-04-10 10:38:12

回答

4

有一个example available

using DataMatrix.net;    // Add ref to DataMatrix.net.dll 
    using System.Drawing;    // Add ref to System.Drawing. 
    [...] 

    // --------------------------------------------------------------- 
    // Date  180310 
    // Purpose Get text from a DataMatrix image. 
    // Entry  sFileName - Name of the barcode file (PNG, + path). 
    // Return The text. 
    // Comments See source, project DataMatrixTest, Program.cs. 
    // --------------------------------------------------------------- 
    private string DecodeText(string sFileName) 
    { 
     DmtxImageDecoder decoder = new DmtxImageDecoder(); 
     System.Drawing.Bitmap oBitmap = new System.Drawing.Bitmap(sFileName); 
     List<string> oList = decoder.DecodeImage(oBitmap); 

     StringBuilder sb = new StringBuilder(); 
     sb.Length = 0; 
     foreach (string s in oList) 
     { 
      sb.Append(s); 
     } 
     return sb.ToString(); 
    } 

你需要DataMatrix.net

+0

我试图使用它,但它无法正确解码unicode字符(这是2年前,我猜) - 我编码的字符串,其中包含俄罗斯字符,它没有给我正确的解码结果。 – cookieMonster 2012-04-11 12:10:34

+1

@cookieMonster实际上DataMatrix.net是用于编码和解码DataMatrix代码(基于libdmtx的.net端口)的一个C#/ .net库,它基于你建议的libdtmx。顺便说一句 - 你遇到俄罗斯字符时,你提交了错误票@ DataMatrix.net吗? – 2012-04-11 12:38:28

+0

它可能是'基于'的,但它不是.net端口,libdmtx有它自己的端口,它在解码方面效果更好。 – cookieMonster 2012-04-11 12:43:14

2

我用过的最好的免费Datamatrix编码器\解码器是libdmtx:http://www.libdmtx.org/。它有c#封装,所以随时可以使用它。我现在不能写样本代码,但如果你自己无法处理,我会稍后再帮你。

编辑: libdmtx附带控制台实用程序 - 如果您将能够使用控制台应用程序读取您的条形码,您一定会使用代码阅读它。

EDIT2: 这里的代码示例:http://libdmtx.wikidot.com/libdmtx-net-wrapper

不知你是否有包含其他一些信息,除了条形码图片。事情是 - 我不知道任何免费的\开放源码库来处理查找图片上的条形码,包含任何其他数据正确。 这里是其他数据矩阵实现的链接:http://www.libdmtx.org/resources.php