asp.net中如何用Image显示Bitmap
代言
代言 2016-11-07 15:07:18
0
1
1497

在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的控件查看是显示正常的说。。。。

代言
代言

reply all (1)
季伟

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();

    Latest Downloads
    More>
    Web Effects
    Website Source Code
    Website Materials
    Front End Template
    About us Disclaimer Sitemap
    php.cn:Public welfare online PHP training,Help PHP learners grow quickly!