最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

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

 更新時(shí)間:2016年12月04日 11:10:58   投稿:hebedich  
本文給大家匯總了幾種C#使用第三方組件生成二維碼的方法以及示例,非常的簡(jiǎn)單實(shí)用,都是項(xiàng)目中經(jīng)常需要用到的,希望大家能夠喜歡

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

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

1.1):首先通過VS2015的NuGet下載對(duì)應(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ì)信息請(qǐng)參考如下鏈接:

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下載對(duì)應(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主要是防止編碼的字符串太長(zhǎng)時(shí)發(fā)生錯(cuò)誤)
      encoder.QRCodeErrorCorrect = QRCodeEncoder.ERROR_CORRECTION.M;//錯(cuò)誤效驗(yàn)、錯(cuò)誤更正(有4個(gè)等級(jí))
      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下載對(duì)應(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ì)信息請(qǐng)參考如下鏈接:

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)

下載對(duì)應(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)的正版,詳情請(qǐng)參考如下鏈接:

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

相關(guān)文章

最新評(píng)論

双柏县| 莫力| 瑞安市| 农安县| 齐河县| 南溪县| 大田县| 柯坪县| 金寨县| 天等县| 海淀区| 南川市| 灌云县| 湛江市| 石林| 林周县| 体育| 绵阳市| 红原县| 嫩江县| 大化| 志丹县| 锡林郭勒盟| 吐鲁番市| 勃利县| 建始县| 筠连县| 若羌县| 丘北县| 楚雄市| 格尔木市| 台前县| 盘锦市| 舟山市| 宁都县| 福鼎市| 渭南市| 东丰县| 巍山| 五指山市| 宜君县|