本文实例讲述了asp.net实现图片以二进制流输出的两种方法。分享给大家供大家参考,具体如下:
方法一:
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();
您可能感兴趣的文章:
声明:本站(华域联盟www.cnhackhy.com)所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。

评论(0)