欧美大屁股bbbbxxxx,狼人大香伊蕉国产www亚洲,男ji大巴进入女人的视频小说,男人把ji大巴放进女人免费视频,免费情侣作爱视频

歡迎來到入門教程網(wǎng)!

C#教程

當(dāng)前位置:主頁 > 軟件編程 > C#教程 >

C#使用第三方組件生成二維碼匯總

來源:本站原創(chuàng)|時間:2020-01-10|欄目:C#教程|點(diǎn)擊: 次

用C#如何生成二維碼,我們可以通過現(xiàn)有的第三方dll直接來實(shí)現(xiàn),下面列出幾種不同的生成方法:

1.通過QrCodeNet(Gma.QrCodeNet.Encoding.dll)來實(shí)現(xiàn)

1.1):首先通過VS2015的NuGet下載對應(yīng)的第三方組件,如下圖所示:

1.2):具體生成二維碼方法如下

    private void GenerateQRByQrCodeNet()
    {
      QrEncoder qrEncoder = new QrEncoder(ErrorCorrectionLevel.H);
      QrCode qrCode = new QrCode();
      qrEncoder.TryEncode("Hello World. This is Eric Sun Testing...", out qrCode);

      GraphicsRenderer renderer = new GraphicsRenderer(new FixedModuleSize(5, QuietZoneModules.Two), Brushes.Black, Brushes.White);

      using (MemoryStream ms = new MemoryStream())
      {
        renderer.WriteToStream(qrCode.Matrix, ImageFormat.Png, ms);
        Image img = Image.FromStream(ms);
        img.Save("E:/csharp-qrcode-net.png");
      }
    }

更多詳細(xì)信息請參考如下鏈接:

http://qrcodenet.codeplex.com/

http://stackoverflow.com/questions/7020136/free-c-sharp-qr-code-generator

2.通過ThoughtWorks.QRCode(ThoughtWorks.QRCode.dll)來實(shí)現(xiàn)

1.1):首先通過VS2015的NuGet下載對應(yīng)的第三方組件,如下圖所示:

1.2):具體生成二維碼方法如下

    private void GenerateQRByThoughtWorks()
    {
      QRCodeEncoder encoder = new QRCodeEncoder();
      encoder.QRCodeEncodeMode = QRCodeEncoder.ENCODE_MODE.BYTE;//編碼方式(注意:BYTE能支持中文,ALPHA_NUMERIC掃描出來的都是數(shù)字)
      encoder.QRCodeScale = 4;//大小(值越大生成的二維碼圖片像素越高)
      encoder.QRCodeVersion = 0;//版本(注意:設(shè)置為0主要是防止編碼的字符串太長時發(fā)生錯誤)
      encoder.QRCodeErrorCorrect = QRCodeEncoder.ERROR_CORRECTION.M;//錯誤效驗(yàn)、錯誤更正(有4個等級)
      encoder.QRCodeBackgroundColor = Color.Yellow;
      encoder.QRCodeForegroundColor = Color.Green;
      string qrdata = "Hello 世界! This is Eric Sun Testing....";

      Bitmap bcodeBitmap = encoder.Encode(qrdata.ToString());
      bcodeBitmap.Save(@"E:\HelloWorld.png", ImageFormat.Png);
      bcodeBitmap.Dispose();
    }

3):通過Spire.BarCode(Spire.BarCode.dll)來實(shí)現(xiàn)

1.1):首先通過VS2015的NuGet下載對應(yīng)的第三方組件,如下圖所示:

1.2):具體生成二維碼方法如下

    private void GenerateQRBySpire()
    {
      BarcodeSettings bs = new BarcodeSettings()
      {
        Data = "This is qr code.",
        Type = BarCodeType.QRCode,
        TopTextColor = Color.Red,
        ShowCheckSumChar = false,
        ShowText = false
      };
      //Generate the barcode based on the this.barCodeControl1
      BarCodeGenerator generator = new BarCodeGenerator(bs);
      Image barcode = generator.GenerateImage();

      //save the barcode as an image
      barcode.Save(@"E:\barcode-2d.png");
    }

1.3):附加具體生成條形碼方法如下

    private void GenerateBarCodeBySpire()
    {
      BarcodeSettings bs = new BarcodeSettings()
      {
        Data = "This is barcode.",
        ShowCheckSumChar = false,
        TopTextColor = Color.Red,
        ShowTopText = false,
        ShowTextOnBottom = true
      };
      //Generate the barcode based on the this.barCodeControl1
      BarCodeGenerator generator = new BarCodeGenerator(bs);
      Image barcode = generator.GenerateImage();

      //save the barcode as an image
      barcode.Save(@"E:\barcode.png");
    }

更多詳細(xì)信息請參考如下鏈接:

http://freebarcode.codeplex.com/

http://www.e-iceblue.com/Knowledgebase/Spire.BarCode/Program-Guide/Programme-Guide-for-Spire.BarCode.html

3.通過BarcodeLib(BarcodeLib.Barcode.ASP.NET.dll)來實(shí)現(xiàn)

下載對應(yīng)dll的連接為 http://www.barcodelib.com/asp_net/

4.1):具體生成二維碼方法如下

    private void GenerateQRByBarcodeLib()
    {
      QRCode qrbarcode = new QRCode();
      qrbarcode.Encoding = QRCodeEncoding.Auto;
      qrbarcode.Data = "336699885522 This is Eric Sun Testing.";

      qrbarcode.ModuleSize = 10;
      qrbarcode.LeftMargin = 8;
      qrbarcode.RightMargin = 8;
      qrbarcode.TopMargin = 8;
      qrbarcode.BottomMargin = 8;
      qrbarcode.ImageFormat = System.Drawing.Imaging.ImageFormat.Gif;

      // Save QR Code barcode image into your system
      qrbarcode.drawBarcode("E:/csharp-qrcode-lib.gif");
    }

4.2):附加具體生成條形碼方法如下

    private void GenerateLinearByBarcodeLib()
    {
      Linear barcode = new Linear();
      barcode.Type = BarcodeType.CODE128;
      barcode.Data = "CODE128";
      // other barcode settings.

      // save barcode image into your system
      barcode.drawBarcode("E:/barcode.png");
    }

我們使用的是試用版(帶水印的......),還有付費(fèi)的正版,詳情請參考如下鏈接:

http://www.barcodelib.com/asp_net/

上一篇:C# this關(guān)鍵字的四種用法

欄    目:C#教程

下一篇:c# 實(shí)現(xiàn)輪詢算法實(shí)例代碼

本文標(biāo)題:C#使用第三方組件生成二維碼匯總

本文地址:http://mengdiqiu.com.cn/a1/C_jiaocheng/6133.html

網(wǎng)頁制作CMS教程網(wǎng)絡(luò)編程軟件編程腳本語言數(shù)據(jù)庫服務(wù)器

如果侵犯了您的權(quán)利,請與我們聯(lián)系,我們將在24小時內(nèi)進(jìn)行處理、任何非本站因素導(dǎo)致的法律后果,本站均不負(fù)任何責(zé)任。

聯(lián)系QQ:835971066 | 郵箱:835971066#qq.com(#換成@)

Copyright © 2002-2020 腳本教程網(wǎng) 版權(quán)所有