实现功能:
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#如何生成二维码的示例分享的详细内容,更多请关注php中文网其它相关文章!
声明:本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn核实处理。
程序员必备接口测试调试工具:点击使用
Apipost = Postman + Swagger + Mock + Jmeter
Api设计、调试、文档、自动化测试工具
网页生成APP,用做网站的技术去做APP:立即创建
手机网站开发APP、自助封装APP、200+原生模块、2000+映射JS接口按需打包
相关文章
相关视频