码迷,mamicode.com
首页 > 其他好文 > 详细

ZXing生成二维码

时间:2016-05-23 14:49:50      阅读:178      评论:0      收藏:0      [点我收藏+]

标签:

dll:http://files.cnblogs.com/files/jake-ge/ZXing.rar

引入命名空间

using System.Drawing;
using System.IO;
using ZXing;
using ZXing.Common;

    public byte[] GenBarCode(string Contents)
    {
        EncodingOptions options = new EncodingOptions();
        BarcodeWriter writer = null;
        options.Width = 50;
        options.Height = 50;
        writer = new BarcodeWriter();
        writer.Format = BarcodeFormat.QR_CODE;
        writer.Options = options;

        Bitmap bitmap = writer.Write(Contents);
        MemoryStream ms = new MemoryStream();
        bitmap.Save(ms, System.Drawing.Imaging.ImageFormat.Bmp);
        byte[] bytes = ms.GetBuffer();
        ms.Close();
        return bytes;
    }

 

ZXing生成二维码

标签:

原文地址:http://www.cnblogs.com/jake-ge/p/5519720.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!