在asp.net中使用ThoughtWorks.QRCode出现问题,生成的图片发送前台不能显示。
QRCodeEncoder qrCodeEncoder = new QRCodeEncoder(); qrCodeEncoder.QRCodeEncodeMode = QRCodeEncoder.ENCODE_MODE.BYTE; qrCodeEncoder.QRCodeScale = 4; qrCodeEncoder.QRCodeVersion = 7; qrCodeEncoder.QRCodeErrorCorrect = QRCodeEncoder.ERROR_CORRECTION.M; Bitmap img = qrCodeEncoder.Encode("123456"); MemoryStream ms = new MemoryStream(); img.Save(ms, System.Drawing.Imaging.ImageFormat.Gif); context.Response.ClearContent(); context.Response.ContentType = "image/Gif"; context.Response.Write(ms.ToArray()); context.Response.End();
我想应该和验证码生成一样的才对,用一个image控件引入生成页面链接,但是窝的就是显示不粗来,是哪里出错了?表示生成的图片用windowsform的控件查看是显示正常的说。。。。
大家讲道理2016-11-07 15:07:41
QRCodeEncoder qrCodeEncoder = new QRCodeEncoder(); qrCodeEncoder.QRCodeEncodeMode = QRCodeEncoder.ENCODE_MODE.BYTE; qrCodeEncoder.QRCodeScale = 4; qrCodeEncoder.QRCodeVersion = 7; qrCodeEncoder.QRCodeErrorCorrect = QRCodeEncoder.ERROR_CORRECTION.M; Bitmap img = qrCodeEncoder.Encode("123456"); MemoryStream ms = new MemoryStream(); img.Save(ms, System.Drawing.Imaging.ImageFormat.Gif); context.Response.ClearContent(); context.Response.ContentType = "image/Gif"; context.Response.BinaryWrite(ms.ToArray());//这里的Write改成BinaryWrite即可 context.Response.End();