日期:2014-05-20  浏览次数:20367 次

100分求解Image如何显示内存中的图片?
各位大哥,在.NET的WEB程序中,Image控件如何显示内存中的图片,因为图片是经过加密的,解密后在的内存中。或者有其它的解决的好办法,谢谢!

------解决方案--------------------
Image的ImageUrl连接到一个a.aspx。
a.aspx的Page_Load中用Response.BinaryWrite(bys);其中bys是内存中图像的字节序列。

应该注意的是,你要把解密后的图片存成内存文件然后取字节,就是说内存文件的字节与我们平时用的硬盘文件字节完全一样,不要缺个头少个尾的。

顺便问一句,这样加密有什么用?到客户端都是Base64,把它考出来就能复原成内存文件的样子。
------解决方案--------------------
create a memory stream from byte[], and pass the stream to the image
------解决方案--------------------
byte[] bytes = null;// //这时百取得bytes的代码 System.IO.MemoryStream ms = new System.IO.MemoryStream(); ms.Write(bytes,0,bytes.Length); Bitmap bmp = new Bitmap(ms); bmp.Save(Response.OutputStream,System.Drawing.Imaging.ImageFormat.Jpeg);
------解决方案--------------------
但是我是想把图片显示在Image控件上啊,或者是ImageButton上,不是直接输出到网页上,因为还想布局显示许多小图片,当点击小图片后再放大。 =================== 如果又不想保存在硬盘上的话,做个单独的页面,显示图片 <img src= "showimg.aspx "> 在showimg.aspx中写上 byte[] bytes = null;// //这时 取得bytes的代码 System.IO.MemoryStream ms = new System.IO.MemoryStream(); ms.Write(bytes,0,bytes.Length); Bitmap bmp = new Bitmap(ms); bmp.Save(Response.OutputStream,System.Drawing.Imaging.ImageFormat.Jpeg);
------解决方案--------------------
取得bytes的代码
System.IO.MemoryStream ms = new System.IO.MemoryStream();
ms.Write(bytes,0,bytes.Length);
Bitmap bmp = new Bitmap(ms);
ImageButton.Image = bmp;
------解决方案--------------------
<img src= "showimg.aspx "> 在showimg.aspx中写上 byte[] bytes = null;// //这时 取得bytes的代码 System.IO.MemoryStream ms = new System.IO.MemoryStream(); ms.Write(bytes,0,bytes.Length); Bitmap bmp = new Bitmap(ms); bmp.Save(Response.OutputStream,System.Drawing.Imaging.ImageFormat.Jpeg);
------解决方案--------------------
You need to decide the item to be displayed. It is your business logic.