c#如何生成二维码的示例分享

引用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#如何生成二维码的示例分享的详细内容,更多请关注创想鸟其它相关文章!

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。
如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件至 chuangxiangniao@163.com 举报,一经查实,本站将立刻删除。
发布者:程序猿,转转请注明出处:https://www.chuangxiangniao.com/p/1432648.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2025年12月17日 08:28:44
下一篇 2025年12月17日 08:28:58

相关推荐

发表回复

登录后才能评论
关注微信