zoukankan      html  css  js  c++  java
  • c#二维码建立与识别

    QrCodeEncodingOptions options = new QrCodeEncodingOptions();
    options.CharacterSet = "UTF-8";
    options.DisableECI = true; // Extended Channel Interpretation (ECI) 主要用于特殊的字符集。并不是所有的扫描器都支持这种编码。
    options.ErrorCorrection = ZXing.QrCode.Internal.ErrorCorrectionLevel.H; // 纠错级别
    options.Width = 300;
    options.Height = 300;
    options.Margin = 1;
    // options.Hints,更多属性,也可以在这里添加。
     
    BarcodeWriter writer = new BarcodeWriter();
    writer.Format = BarcodeFormat.QR_CODE;
    writer.Options = options;
     
    Response.Clear();
    using (Bitmap bmp = writer.Write("http://www.cftea.com")) // Write 具备生成、写入两个功能
    {
     MemoryStream ms = new MemoryStream();
     {
      bmp.Save(ms, System.Drawing.Imaging.ImageFormat.Png);
     
      Response.ContentType = "image/png";
      Response.BinaryWrite(ms.ToArray());
     }
    }
    Response.End();
     
     
     
    QrCodeEncodingOptions options = new QrCodeEncodingOptions();
    options.CharacterSet = "UTF-8";
    options.Width = 300;
    options.Height = 50;
    options.Margin = 1;
    options.PureBarcode = false; // 是否是纯码,如果为 false,则会在图片下方显示数字
     
    BarcodeWriter writer = new BarcodeWriter();
    writer.Format = BarcodeFormat.CODE_128;
    writer.Options = options;
     
    Response.Clear();
    using (Bitmap bmp = writer.Write("12345678"))
    {
     MemoryStream ms = new MemoryStream();
     {
      bmp.Save(ms, System.Drawing.Imaging.ImageFormat.Png);
     
      Response.ContentType = "image/png";
      Response.BinaryWrite(ms.ToArray());
     }
    }
    Response.End();
     
     
    BarcodeReader reader = new BarcodeReader();
    reader.Options.CharacterSet = "UTF-8";
    using (Bitmap bmp = new Bitmap("D:\qr.png"))
    {
     Result result = reader.Decode(bmp);
     Response.Write(result.Text);
    }
  • 相关阅读:
    Nginx Rewrite详解
    linux下面mysql的基本命令
    通过淘宝的rubygems镜像,安装rubygems
    PHP 调用函数时,函数名称前面加@的作用
    mysql5.5中 host的值为::1
    CentOS 6.2编译安装Nginx1.2.0+MySQL5.5.25+PHP5.3.13+博客系统WordPress3.3.2
    ruby数组方法concat和push的区别
    PHP 的时间格式
    EOF与getchar
    控件台版/MFC版本的简单生日提醒软件及源码
  • 原文地址:https://www.cnblogs.com/qqhfeng/p/8984511.html
Copyright © 2011-2022 走看看