try System.Web.HttpContext.Current.Response.OutputStreambut you may want to redesign your code, so that, your method will be passed a Stream objectvoid YourMethod(Stream m) { ///.... objBitmap.Save(m, System.Drawing.Imaging.ImageFormat.Jpeg) }then in your ASP.NET, you will callYourMethod(Response.OutputStream);
{
///....
objBitmap.Save(m, System.Drawing.Imaging.ImageFormat.Jpeg)
}then in your ASP.NET, you will callYourMethod(Response.OutputStream);
if (dr != null)
{
string fileType = dr["LogoFileType"].ToString();//图片类型
System.Web.HttpContext.Current.Response.ContentType = "image/"+fileType;
System.Drawing.Image _image = System.Drawing.Image.FromStream( new System.IO.MemoryStream( (byte[])dr["LogoFile"] ) );//dr["LogoFile"]是图片信息
switch (fileType)
{
case "jpg":
_image.Save( System.Web.HttpContext.Current.Response.OutputStream, System.Drawing.Imaging.ImageFormat.Jpeg );
break;
case "bmp":
_image.Save( System.Web.HttpContext.Current.Response.OutputStream, System.Drawing.Imaging.ImageFormat.Bmp );
break;
case "gif":
_image.Save( System.Web.HttpContext.Current.Response.OutputStream, System.Drawing.Imaging.ImageFormat.Gif );
break;
case "png":
_image.Save( System.Web.HttpContext.Current.Response.OutputStream, System.Drawing.Imaging.ImageFormat.Png );
break;
}
}