Asp.net implements two methods for outputting images in binary streams,

Source: Internet
Author: User

Asp.net implements two methods for outputting images in binary streams,

This example describes two methods for asp.net to output images in binary streams. We will share this with you for your reference. The details are as follows:

Method 1:

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

Method 2:

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

I hope this article will help you design your asp.net program.

Articles you may be interested in:
  • ASP. NET stores images in binary format into the database
  • Asp.net saves an image as a binary value to the instance code in the Xml file.
  • Asp.net (c #) implements code for accessing binary images from sqlserver
  • Asp.net Remote Image Upload Method Based on Web Service
  • ASP. NET
  • Implementation of ASP. NET gradient display images
  • Three typical ASP. NET image processing problems
  • Examples of Image Display Methods in ASP. NET

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.