Store promotions asp.net generate two-dimensional code, the middle of the two-dimensional code plus logo (source)

Dimensional bar code according to the amount of data than a more dimensional bar codes, two-dimensional barcode is a high density, portable data file high information content, and other cards and documents, is to achieve a large capacity, high reliability information is automatically stored, and can be carried automatic machine ideal means of reading. And it can record more complex data, such as pictures.

This article demonstrates asp.net used to generate two-dimensional code store promotion, the intermediate results generated logo added two-dimensional code shown in FIG 1. The demo program uses text to turn into images, generate thumbnails, and other images together to provide a complete source code in the code download accompanying.

FIG 1 program generation effect

Demo program structure

Create a demo program, I chose to create a new blank C # Web site project in Visual Studio 2013, the project was named CreateQRCode, add the default display page Default.aspx, general handler QRCode.ashx is the core of the demonstration program, a two-dimensional code processing ThoughtWorks.QRCode .dll, background images background.jpg and small head HeadPortrait.jpg. Figure 2 shows the overall structure of the demo program.

image

FIG 2 is an overall configuration program

He cited three namespace QRCode.ashx, as follows

image

Achieve System.Web.SessionState.IRequiresSessionState, you can use HttpContext.Current.Session QRCode.ashx in general handler.

In the two-dimensional code generation method GetQRCode, storing parameters to be encoded content, defined as follows:

image

In three parameters CreateImg method may come from other pages, defined as follows:

image

In the method for converting text into ConvertStringToImage image, defined as follows:

image

Generating a thumbnail picture MakeThumbnail method is defined as follows:

image

image

In the method of CombinImage New Custom height, width, background color image, defined as follows:


End

本文演示使用asp.net生成店铺推广二维码,二维码中间加logo生成效果如图1。该演示程序使用到了文字转成图片,生成缩略图,图片拼接等,在随附的代码下载中提供了完整的源代码。完整的源代码下载链接

发布了7 篇原创文章 · 获赞 1 · 访问量 5695

Guess you like

Origin blog.csdn.net/limingblogs/article/details/51210018