zoukankan      html  css  js  c++  java
  • 一个C#二维码图片识别

    https://www.cnblogs.com/xuezhizhang/p/8968515.html

    关键是这个 ThoughtWorks.QRCode.Codec;

    NuGet直接下载就可以了

    /// <summary>
             /// 读取图片文件,识别二维码
             /// </summary>
            /// <param name="filePath">图片文件路劲</param>
             /// <returns>识别结果字符串</returns>
             public static string CodeDecoder(string filePath)
             {
                 string decoderStr;
                 try
                 {
                     if (!System.IO.File.Exists(filePath))//判断有没有需要读取的主文件夹,如果不存在,终止  
                         return null;
    
                     Bitmap bitMap = new Bitmap(Image.FromFile(filePath));//实例化位图对象,把文件实例化为带有颜色信息的位图对象  
                     QRCodeDecoder decoder = new QRCodeDecoder();//实例化QRCodeDecoder  
    
                     //通过.decoder方法把颜色信息转换成字符串信息  
                     decoderStr = decoder.decode(new QRCodeBitmapImage(bitMap), System.Text.Encoding.UTF8);
                 }
                 catch (Exception ex)
                 {
                     throw ex;
                }
    
                 return decoderStr;//返回字符串信息  
             }
  • 相关阅读:
    生成器函数
    初识函数
    格式化输出
    流程控制-while循环
    流程控制if语句
    Python入门
    Eclipse搭建C++开发环境
    Android SQLite基本用法
    Android拍照后更新相册
    操作系统相册和获取相册路径
  • 原文地址:https://www.cnblogs.com/LuoEast/p/12692815.html
Copyright © 2011-2022 走看看