引用zxing类库
实现功能:
1生成带有Logo二维码
2 将二维码绘制到图片上
3 图片上绘制文字
bee餐饮点餐外卖小程序是针对餐饮行业推出的一套完整的餐饮解决方案,实现了用户在线点餐下单、外卖、叫号排队、支付、配送等功能,完美的使餐饮行业更高效便捷!功能演示:1、桌号管理登录后台,左侧菜单 “桌号管理”,添加并管理你的桌号信息,添加以后在列表你将可以看到 ID 和 密钥,这两个数据用来生成桌子的二维码2、生成桌子二维码例如上面的ID为 308,密钥为 d3PiIY,那么现在去左侧菜单微信设置
1
生成二维码
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中文网其它相关文章!
每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号