网创优客建站品牌官网
为成都网站建设公司企业提供高品质网站建设
热线:028-86922220
成都专业网站建设公司

定制建站费用3500元

符合中小企业对网站设计、功能常规化式的企业展示型网站建设

成都品牌网站建设

品牌网站建设费用6000元

本套餐主要针对企业品牌型网站、中高端设计、前端互动体验...

成都商城网站建设

商城网站建设费用8000元

商城网站建设因基本功能的需求不同费用上面也有很大的差别...

成都微信网站建设

手机微信网站建站3000元

手机微信网站开发、微信官网、微信商城网站...

建站知识

当前位置:首页 > 建站知识

c#生成二维码的方法

小编给大家分享一下c#生成二维码的方法,希望大家阅读完这篇文章后大所收获,下面让我们一起去探讨吧!

创新互联专业IDC数据服务器托管提供商,专业提供成都服务器托管,服务器租用,成都服务器托管成都服务器托管,成都多线服务器托管等服务器托管服务。

                                                           引用ZXing类库

实现功能:

1生成带有Logo二维码

2 将二维码绘制到图片上

3 图片上绘制文字

生成二维码

public string CreateQrCode(string md5Str,string name,int sex)
        {
            string str = sex == 1? "先生":"女士";
            string logoPath = AppDomain.CurrentDomain.BaseDirectory + "/logo.png";
            string qrCodePath = path + DateTime.Now.ToString("yyyyMMddHHmmss") + ".jpg";
            string yqPath = AppDomain.CurrentDomain.BaseDirectory + "/yq2.jpg";
            string yqCardPath = path + TCommon.Md5(DateTime.Now.ToString("yyyyMMddHHmmss")) + ".jpg";
            if (Directory.Exists(path) == false)//如果不存在就创建file文件夹
            {
                Directory.CreateDirectory(path);
            }
            Generate3(md5Str,logoPath,qrCodePath);
            Image qrCodeImg = new Bitmap(qrCodePath);
            Image image = new Bitmap(yqPath);
            Graphics ig = Graphics.FromImage(image);
            Font font = new Font("Arial", 38,FontStyle.Bold); 
            Font font2 = new Font("STXINWEI", 38, FontStyle.Bold);
            Brush brush = System.Drawing.Brushes.Black;
            SizeF size = ig.MeasureString(name, font2);
            SizeF size2 = ig.MeasureString(str, font);
            ig.DrawString(name, font, brush, (720-size.Width-size2.Width) /2, 680);
            ig.DrawString(str, font, brush, (720 - size.Width - size2.Width) / 2 + size.Width, 680);
            ig.FillRectangle(Brushes.White, 280, 351, 160, 160);
            ig.DrawImage(qrCodeImg, 285, 356);
            image.Save(yqCardPath);
            return yqCardPath.Substring(2);
        }

图片上生成文字

看完了这篇文章,相信你对c#生成二维码的方法有了一定的了解,想了解更多相关知识,欢迎关注创新互联行业资讯频道,感谢各位的阅读!


当前文章:c#生成二维码的方法
网页链接:http://bjjierui.cn/article/ihhoie.html

其他资讯