生成二维码(内嵌logo)条形码大全[附源码下载]

CSDN的编辑器出现问题,都乱码了,重新排版了,

请点击:https://blog.csdn.net/djk8888/article/details/80938227




本例配套源码下载:https://download.csdn.net/download/djk8888/10505344

用到了:jquery.qrcode.js(实现简单,推荐此法)、ThoughtWorks.QRCode.dll等

HTML:




    
    生成二维码
    
    
    
    


    

一行代码写法:

标准写法:

内嵌LOGO写法:

用webAPI接口的写法:

用ThoughtWorks.QRCode.dll组件生成:

生成条形码(API):

QRCode.ashx(ThoughtWorks.QRCode.Codec;)

<%@ WebHandler Language="C#" Class="QRCode" %>

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Web;
using ThoughtWorks.QRCode.Codec;



public class QRCode : IHttpHandler
{
    public void ProcessRequest(HttpContext context)
    {
        try
        {
            string data = context.Request.QueryString["qrUrl"];
            QRCodeEncoder qrCodeEncoder = new QRCodeEncoder();
            qrCodeEncoder.QRCodeEncodeMode = QRCodeEncoder.ENCODE_MODE.BYTE;      //byte类型
            qrCodeEncoder.QRCodeScale = 4;     //大小
            qrCodeEncoder.QRCodeVersion = 7;   //版本               
            qrCodeEncoder.QRCodeErrorCorrect = QRCodeEncoder.ERROR_CORRECTION.M;  //等级


            //将bitmap格式的数据转换成byte格式
            byte[] img = ImageToByteArray(qrCodeEncoder.Encode(data));


            context.Response.ContentType = "image/jpeg";     //输出的文本格式
            context.Response.BinaryWrite(img);               //将二进制输出
            context.Response.Flush();
            context.Response.End();
        }
        catch { }
    }
    public byte[] ImageToByteArray(System.Drawing.Image imageIn)
    {
        MemoryStream ms = new MemoryStream();
        imageIn.Save(ms, System.Drawing.Imaging.ImageFormat.Gif);
        return ms.ToArray();
    }
    public bool IsReusable
    {
        get
        {
            return false;
        }
    }
}

效果如图:

生成二维码(内嵌logo)条形码大全[附源码下载]_第1张图片

可以拿出手机扫一扫

本例配套源码下载:https://download.csdn.net/download/djk8888/10505344

你可能感兴趣的:(二维码,条形码,html,jquery,ASP.NET代码,JS代码)