当前位置:网站首页>【博主推荐】C#生成好看的二维码(附源码)
【博主推荐】C#生成好看的二维码(附源码)
2022-07-06 09:13:00 【xcLeigh】
【博主推荐】C#生成好看的二维码(附源码)
- 实现功能
1.实现二维码生成
2.实现二维码样式修改
3.实现条件下,批量生成
4.实现样式,地址等参数可配置
1.效果展示
1.1 界面效果
1.2 生成后界面效果
1.1 界面配置后生成的二维码
2.二维码页面设计
<div style="background-color:white;width:100%; text-align:center;">
<div class="layui-field-box" style="background-color:orange;">
<div>
<table style="width:100%;">
<tr>
<td style="color:black;">
xcLeigh - 二维码生成
</td>
<td style="text-align:right;font-size:13px;color:white;">
<a href="https://download.csdn.net/user/weixin_43151418/?spm=1003.2020.3001.5449">【博主推荐】相关资源</a> |
<a href="https://download.csdn.net/download/weixin_43151418/85329413?spm=1003.2166.3001.6637.6">C#MVC后台管理系统(附源码)</a> |
<a href="https://download.csdn.net/download/weixin_43151418/85337361?spm=1003.2166.3001.6637.1">html下拉框树形(附好看的登录界面)</a> |
<a href="https://download.csdn.net/download/weixin_43151418/85335759">HTML5响应式手机微网站(附源码)</a> |
<a href="https://download.csdn.net/download/weixin_43151418/85336631">html操作SVG图(附源码)</a>
</td>
</tr>
</table>
</div>
</div>
<hr style="margin:0px;padding:0px;margin-bottom:5px;" />
@*<div style="text-align:center; padding:15px;color:red;">
<span id="tomessage">转换成功,位置在D:\\</span>
</div>*@
<div class="layui-upload-drag" id="zjImg" style="margin-bottom:5px;">
<img id="ewmImg" name="ewmImg" src="~/Content/xcsharp/images/lo.png" style="width:80px;height:80px;" />
<div style="padding:2px;"></div>
<p style="color:crimson;">二维码Logo</p>
</div>
<input id="ewmImgt" name="ewmImgt" hidden="hidden" type="text" value="Content\\xcsharp\\images\\lo.png">
<div class="layui-upload-drag" id="scImg" style="margin-bottom:5px;display:none;">
<img class="img1" src="@ViewBag.ImgScEwm" style="width:150px;height:150px;" />
<div style="padding:2px;"></div>
<p style="color:crimson;">生成成功</p>
<p style="color:crimson;">右键图片另存为,保存二维码</p>
</div>
<div style="text-align:left; margin:10px;">
<input id="ewmAddr" name="ewmAddr" class="layui-input" type="text" placeholder="二维码定义:可以是地址,可以是特定字符" autocomplete="off" lay-verify="required" lay-reqtext="二维码定义是必填项,岂能为空?">
</div>
<div style="text-align:left; margin:10px;">
<input id="ewmWz" name="ewmWz" class="layui-input" type="text" placeholder="底部文字可加可不加,最长8个字符" maxlength="8" autocomplete="off">
</div>
<div style="text-align:left; margin:10px;">
<table>
<tr>
<td>背景色:</td>
<td>
<div style="margin-top:18px;">
<div class="layui-form-item">
<div class="layui-input-inline" style="width: 120px;">
<input type="text" value="#ffffff" placeholder="背景颜色" readonly="readonly" class="layui-input" id="ewmBgColor" name="ewmBgColor">
</div>
<div class="layui-inline" style="left: -11px;">
<div id="ewmBgColor_d"></div>
</div>
</div>
</div>
</td>
<td>二维码颜色:</td>
<td>
<div style="margin-top:18px;">
<div class="layui-form-item">
<div class="layui-input-inline" style="width: 120px;">
<input type="text" value="#1EABFC" placeholder="背景颜色" readonly="readonly" class="layui-input" id="ewmColor" name="ewmColor">
</div>
<div class="layui-inline" style="left: -11px;">
<div id="ewmColor_d"></div>
</div>
</div>
</div>
</td>
<td>文字颜色:</td>
<td>
<div style="margin-top:18px;">
<div class="layui-form-item">
<div class="layui-input-inline" style="width: 120px;">
<input type="text" value="#1EABFC" placeholder="背景颜色" readonly="readonly" class="layui-input" id="ewmFontColor" name="ewmFontColor">
</div>
<div class="layui-inline" style="left: -11px;">
<div id="ewmFontColor_d"></div>
</div>
</div>
</div>
</td>
<td>文字字体:</td>
<td>
<select name="ewmWzFont" lay-filter="aihao">
<option value="黑体" selected="">黑体</option>
<option value="宋体">宋体</option>
<option value="仿宋">仿宋</option>
</select>
</td>
<td style="padding-left:20px;">四个角颜色:</td>
<td>
<div style="margin-top:18px;">
<div class="layui-form-item">
<div class="layui-input-inline" style="width: 120px;">
<input type="text" value="#1EABFC" placeholder="背景颜色" readonly="readonly" class="layui-input" id="ewmSgjColor" name="ewmSgjColor">
</div>
<div class="layui-inline" style="left: -11px;">
<div id="ewmSgjColor_d"></div>
</div>
</div>
</div>
</td>
</tr>
</table>
</div>
<div style="text-align:left; margin:10px;">
<table>
<tr>
<td>是否显示四个角:</td>
<td>
<input name="ewmSgj" type="checkbox" checked="" lay-skin="switch" lay-filter="switchTest" lay-text="显示|隐藏">
</td>
<td></td>
</tr>
</table>
</div>
<div style="text-align:left; margin:10px;">
<button class="layui-btn" data-type="parseTable" type="submit" lay-filter="demo1" lay-submit="">生成二维码</button>
</div>
@*<div class="layui-upload-drag" id="wordtopdf" style="margin-bottom:5px;">
<i class="layui-icon"></i>
<p style="color:crimson;">WORD转PDF(doc格式)</p>
<p>点击上传,或将文件拖拽到此处</p>
</div>*@
</div>
3.二维码生成的后台操作
public ActionResult EwmImg() {
try
{
var file = Request.Files[0]; //获取选中文件
var filecombin = file.FileName.Split('.');
//文件名字
string filename = Path.GetFileName(file.FileName);
if (file == null || filename.IndexOf("&") != -1 || String.IsNullOrEmpty(file.FileName) || file.ContentLength == 0 || filecombin.Length < 2)
{
return Json(new
{
fileid = 0,
src = "",
name = "",
msg = "上传出错 请检查文件名 或 图片格式是否符合"
});
}
//定义本地路径位置
string local = "upload\\ewm\\img\\";
string localPath = Path.Combine(HttpRuntime.AppDomainAppPath, local);
if (!System.IO.Directory.Exists(localPath))
System.IO.Directory.CreateDirectory(localPath);
string newPath = localPath + filename;
file.SaveAs(newPath);
//保存图片
return Json(new
{
src = newPath.Trim().Replace("\\", "|"),
name = filename,
// 获取文件名不含后缀名
msg = "上传成功"
});
}
catch { }
return Json(new
{
src = "",
name = "", // 获取文件名不含后缀名
msg = "上传出错"
});
}
4.源码下载
边栏推荐
- Not registered via @enableconfigurationproperties, marked (@configurationproperties use)
- Adaptive Bezier curve network for real-time end-to-end text recognition
- [BMZCTF-pwn] 11-pwn111111
- MySQL25-索引的创建与设计原则
- Advantages and disadvantages of evaluation methods
- Nanny hand-in-hand teaches you to write Gobang in C language
- Copy constructor template and copy assignment operator template
- CSDN question and answer tag skill tree (II) -- effect optimization
- Mysql24 index data structure
- 保姆级手把手教你用C语言写三子棋
猜你喜欢
保姆级手把手教你用C语言写三子棋
Mysql27 - Optimisation des index et des requêtes
Bytetrack: multi object tracking by associating every detection box paper reading notes ()
UnicodeDecodeError: ‘utf-8‘ codec can‘t decode byte 0xd0 in position 0成功解决
MySQL combat optimization expert 02 in order to execute SQL statements, do you know what kind of architectural design MySQL uses?
Mysql33 multi version concurrency control
Why is MySQL still slow to query when indexing is used?
MySQL23-存储引擎
ZABBIX introduction and installation
Record the first JDBC
随机推荐
Global and Chinese market for intravenous catheter sets and accessories 2022-2028: Research Report on technology, participants, trends, market size and share
Time complexity (see which sentence is executed the most times)
Mysql35 master slave replication
Chrome浏览器端跨域不能访问问题处理办法
MySQL27-索引优化与查询优化
Why is MySQL still slow to query when indexing is used?
Mysql28 database design specification
MySQL combat optimization expert 02 in order to execute SQL statements, do you know what kind of architectural design MySQL uses?
Technology | diverse substrate formats
[BMZCTF-pwn] 11-pwn111111
Development of C language standard
Security design verification of API interface: ticket, signature, timestamp
Mysql26 use of performance analysis tools
Moteur de stockage mysql23
使用OVF Tool工具从Esxi 6.7中导出虚拟机
Use of dataset of pytorch
Security design verification of API interface: ticket, signature, timestamp
基于Pytorch肺部感染识别案例(采用ResNet网络结构)
MySQL26-性能分析工具的使用
Typescript入门教程(B站黑马程序员)