2012-04-10 122 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