加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

c# – 从图像中读取二维条码

发布时间:2020-12-15 08:10:26 所属栏目:百科 来源:网络整理
导读:我需要一个库来从C#项目( windows Forms)上的图像中读取二维条码(datamatrix). 我尝试使用一些SDK,但我尝试的SDK不是免费的. 有没有免费的SDK可以从图像中读取2d条形码? 解决方法 有一个 example available: using DataMatrix.net; // Add ref to DataMatr
我需要一个库来从C#项目( windows Forms)上的图像中读取二维条码(datamatrix).
我尝试使用一些SDK,但我尝试的SDK不是免费的.

有没有免费的SDK可以从图像中读取2d条形码?

解决方法

有一个 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!

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读