In addition to Weibo, there is also WeChat
Please pay attention

WeChat public account
Shulou
2025-11-05 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article is about how asp.net uses QRCode to generate QR codes with Logo or images in the picture center. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.
The details are as follows:
Using System;using System.Web;using ThoughtWorks.QRCode.Codec;using ThoughtWorks.QRCode.Codec.Data;using ThoughtWorks.QRCode.Codec.Util;using System.IO;using System.Text;using System.Drawing;using System.Drawing.Drawing2D;public class GetQRCode: IHttpHandler {public void ProcessRequest (HttpContext context) {String data = context.Request ["CodeText"]; if (! string.IsNullOrEmpty (data)) {QRCodeEncoder qrCodeEncoder = new QRCodeEncoder (); qrCodeEncoder.QRCodeEncodeMode = QRCodeEncoder.ENCODE_MODE.BYTE QrCodeEncoder.QRCodeScale = 4; qrCodeEncoder.QRCodeVersion = 8; qrCodeEncoder.QRCodeErrorCorrect = QRCodeEncoder.ERROR_CORRECTION.M; System.Drawing.Image image = qrCodeEncoder.Encode (data); System.IO.MemoryStream MStream = new System.IO.MemoryStream (); image.Save (MStream, System.Drawing.Imaging.ImageFormat.Png); System.IO.MemoryStream MStream1 = new System.IO.MemoryStream () CombinImage (image, context.Server.MapPath ("~ / images/201292891051540.jpg")) .Save (MStream1, System.Drawing.Imaging.ImageFormat.Png); context.Response.ClearContent (); context.Response.ContentType = "image/png"; context.Response.BinaryWrite (MStream1.ToArray ()); / / image.Dispose (); MStream.Dispose (); MStream1.Dispose ();} context.Response.Flush () Context.Response.End ();} / merge the two pictures after calling this function, similar to a photo album, with a / background image pasted with your own target picture / pasted source picture / pasted target picture public static Image CombinImage (Image imgBack, string destImg) {Image img = Image.FromFile (destImg) / / if (img.Height! = 65 | | img.Width! = 65) {img = KiResizeImage (img, 65, 65, 0);} Graphics g = Graphics.FromImage (imgBack); g.DrawImage (imgBack, 0,0, imgBack.Width, imgBack.Height); / / g.DrawImage (imgBack, 0,0, frame width, frame height) / / g.FillRectangle (System.Drawing.Brushes.White, imgBack.Width / 2-img.Width / 2-1, imgBack.Width / 2-img.Width / 2-1); / / A black border around the photo / / g.DrawImage (img, the left margin between the photo and the frame, the top margin between the photo and the frame, width, height) G.DrawImage (img, imgBack.Width / 2-img.Width / 2, imgBack.Width / 2-img.Width / 2, img.Width, img.Height); GC.Collect (); return imgBack } / Resize picture / original Bitmap / new width / / new height / / retained, temporarily not used / to process the later picture public static Image KiResizeImage (Image bmp, int newW, int newH, int Mode) {try {Image b = new Bitmap (newW, newH); Graphics g = Graphics.FromImage (b) / / quality of interpolation algorithm g.InterpolationMode = InterpolationMode.HighQualityBicubic; g.DrawImage (bmp, new Rectangle (0,0, newW, newH), new Rectangle (0,0, bmp.Width, bmp.Height), GraphicsUnit.Pixel); g.Dispose (); return b;} catch {return null;}} public bool IsReusable {get {return false Thank you for your reading! This is the end of this article on "how asp.net uses QRCode to generate a QR code for a picture center plus Logo or image". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it out for more people to see!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope





About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.