当前位置:网站首页>[recommended by bloggers] C # generate a good-looking QR code (with source code)

[recommended by bloggers] C # generate a good-looking QR code (with source code)

2022-07-06 10:53:00 xcLeigh

【 Bloggers recommend 】C# Generate a good-looking QR code ( Source code attached )

  • Realization function

1. Realize two-dimensional code generation
2. Realize QR code style modification
3. Under the condition of realization , Batch build
4. Implementation style , Address and other parameters can be configured

1. Effect display

1.1 Interface effect

 Insert picture description here

1.2 Interface effect after generation

 Insert picture description here

1.1 QR code generated after interface configuration

 Insert picture description here

2. QR code page design

 <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 -  QR code generation 
                        </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">【 Bloggers recommend 】 Related resources </a> |
                            <a href="https://download.csdn.net/download/weixin_43151418/85329413?spm=1003.2166.3001.6637.6">C#MVC Background management system ( Source code attached )</a> |
                            <a href="https://download.csdn.net/download/weixin_43151418/85337361?spm=1003.2166.3001.6637.1">html Drop down tree ( Attached is a nice login interface )</a> |
                            <a href="https://download.csdn.net/download/weixin_43151418/85335759">HTML5 Responsive mobile wechat ( Source code attached )</a> |
                            <a href="https://download.csdn.net/download/weixin_43151418/85336631">html operation SVG chart ( Source code attached )</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"> Conversion success , Position in 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;"> QR code 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;"> Generate successfully </p>
                <p style="color:crimson;"> Right click to save the picture as , Save QR code </p>
            </div>
            <div style="text-align:left; margin:10px;">
                <input id="ewmAddr" name="ewmAddr" class="layui-input" type="text" placeholder=" QR code definition : It can be an address , It can be a specific character " autocomplete="off" lay-verify="required" lay-reqtext=" QR code definition is required , How can it be empty ?">
            </div>

            <div style="text-align:left; margin:10px;">
                <input id="ewmWz" name="ewmWz" class="layui-input" type="text" placeholder=" The bottom text can be added or not , The longest 8 Characters " maxlength="8" autocomplete="off">
            </div>

            <div style="text-align:left; margin:10px;">
                <table>
                    <tr>
                        <td> Background color :</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=" The background color " 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> QR code color :</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=" The background color " 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> Text color :</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=" The background color " 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> Text font :</td>
                        <td>
                            <select name="ewmWzFont" lay-filter="aihao">
                                <option value=" In black " selected=""> In black </option>
                                <option value=" Song style "> Song style </option>
                                <option value=" Imitation song "> Imitation song </option>
                            </select>

                        </td>
                        <td style="padding-left:20px;"> Four corner color :</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=" The background color " 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> Whether to display four corners :</td>
                        <td>
                            <input name="ewmSgj" type="checkbox" checked="" lay-skin="switch" lay-filter="switchTest" lay-text=" Show | hide ">

                        </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=""> Generate qr code </button>
            </div>
            @*<div class="layui-upload-drag" id="wordtopdf" style="margin-bottom:5px;">
                <i class="layui-icon">&#xe67c;</i>
                <p style="color:crimson;">WORD turn PDF(doc Format )</p>
                <p> Click upload , Or drag the file here </p>
            </div>*@
</div>

3. Background operation of QR code generation

public ActionResult EwmImg() {
try
{
    var file = Request.Files[0]; // Get the selected file                   
    var filecombin = file.FileName.Split('.');
    // File name 
    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 = " Upload error   Please check the file name   or   Whether the image format conforms to "
        });
    }
    // Define the local path location                 
    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);
    // Save the picture             
    return Json(new
    {
        src = newPath.Trim().Replace("\\", "|"),
        name = filename,
        //  Get file name without suffix                     
        msg = " Upload successful "
    });
}
catch { }
return Json(new
{
    src = "",
    name = "",   //  Get file name without suffix                 
    msg = " Upload error "
});
}

4. Source download

【 Bloggers recommend 】C# Generate a good-looking QR code ( Source code )

原网站

版权声明
本文为[xcLeigh]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/187/202207060912197600.html