欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

asp.net實現(xiàn)圖片以二進制流輸出的兩種方法

 更新時間:2015年12月04日 14:25:57   作者:happy664618843  
這篇文章主要介紹了asp.net實現(xiàn)圖片以二進制流輸出的兩種方法,以簡單實例形式分析了asp.net實現(xiàn)以二進制流形式讀寫圖片文件的相關(guān)技巧,具有一定參考借鑒價值,需要的朋友可以參考下

本文實例講述了asp.net實現(xiàn)圖片以二進制流輸出的兩種方法。分享給大家供大家參考,具體如下:

方法一:

System.IO.MemoryStream ms = new System.IO.MemoryStream();
System.IO.Stream str = new FileUpload().PostedFile.InputStream;
System.Drawing.Bitmap map = new System.Drawing.Bitmap(str);
map.Save(ms, System.Drawing.Imaging.ImageFormat.Gif);
Response.ClearContent();
Response.ContentType = "image/gif";
Response.BinaryWrite(ms.ToArray());

方法二:

System.IO.FileStream fs = new System.IO.FileStream("Filename", System.IO.FileMode.Open, System.IO.FileAccess.Read);
byte[] datas = new byte[fs.Length];
fs.Read(datas, 0, Convert.ToInt32(fs.Length));
fs.Close();
Response.OutputStream.Write(datas,0,Convert.ToInt32(fs.Length));
Response.End();

希望本文所述對大家asp.net程序設(shè)計有所幫助。

相關(guān)文章

最新評論