C#生成二维码
/// <summary> /// 生成二维码 ! /// </summary> /// <param name="context"></param> public static void GetQode(HttpContext context) { string url = context.Request["url"]; string Newurl = HttpUtility.UrlDecode(url); Bitmap bt; QRCodeEncoder code = new QRCodeEncoder(); bt = code.Encode(Newurl, Encoding.UTF8);using (Bitmap objBitmap = bt) { if (objBitmap != null) { using (MemoryStream objMS = new MemoryStream()) { objBitmap.Save(objMS, ImageFormat.Jpeg); HttpContext.Current.Response.ClearContent(); HttpContext.Current.Response.ContentType = "image/Jpeg"; HttpContext.Current.Response.BinaryWrite(objMS.ToArray()); HttpContext.Current.Response.Flush(); HttpContext.Current.Response.End(); } } } }
本文来自博客园,作者:方金,转载请注明原文链接:https://www.cnblogs.com/Gold-fangjin/p/6116518.html