//生成一个临时文件
string strTmpFile = System.IO.Path.GetTempFileName();//从临时文件生成一个Stream
System.IO.Stream objStream=System.IO.File.Open(strTmpFile,System.IO.FileMode.Open);//把图片输出到Stream中,bytImage数组中存储了我的图片
objStream.Write(bytImage, 0, bytImage.Length);//从Stream中加载到Image对象
System.Drawing.Image img = System.Drawing.Image.FromStream(objStream);//输出类型:image/jpeg image/gif image/bmp
Response.ContentType = Common.Photo.MimeTypeFromImageFormat(img.RawFormat);/*
输出到Response.OutputStream
如果图片文件是bmp格式了就会出错:GDI+产生一般性错误
但其它文件格式如:gif/jpg都没有问题
*/
img.Save(Response.OutputStream, img.RawFormat);objStream.Close();
Response.Flush();
img.Dispose();
求助各位
string strTmpFile = System.IO.Path.GetTempFileName();//从临时文件生成一个Stream
System.IO.Stream objStream=System.IO.File.Open(strTmpFile,System.IO.FileMode.Open);//把图片输出到Stream中,bytImage数组中存储了我的图片
objStream.Write(bytImage, 0, bytImage.Length);//从Stream中加载到Image对象
System.Drawing.Image img = System.Drawing.Image.FromStream(objStream);//输出类型:image/jpeg image/gif image/bmp
Response.ContentType = Common.Photo.MimeTypeFromImageFormat(img.RawFormat);/*
输出到Response.OutputStream
如果图片文件是bmp格式了就会出错:GDI+产生一般性错误
但其它文件格式如:gif/jpg都没有问题
*/
img.Save(Response.OutputStream, img.RawFormat);objStream.Close();
Response.Flush();
img.Dispose();
求助各位
而不是 别的文件 改了 后缀名?
"image/jpeg"或"image/gif"或"image/bmp"或……
不支持基于bmp格式的图,改成
Image.Save(Response.OutputStream,System.Drawing.Imaging.ImageFormat.Jpeg)就可以了
虽然图片是Bmp格式的
消息可靠否?