Bitmap.Save(Stream, ImageFormat) doesn't change MIME type
I'm doing Bitmap.Save(MemoryStream, ImageFormat.Gif)
on a JPG source image, but when checking the MIME type of the MemoryStream the image is saved to, I still get image/jpeg
. Judging from the greatly reduced quality of the returned image, I'm certain that the actual conversion is taking place, but at the same time I'm also sure that the MIME type is also being read correctly.
Could there be something wrong wi开发者_如何学Goth my code or is this normal for Bitmap.Save
?
Assuming (judging by your previous question) this is ASP.NET / HTTP in general you have to set the content type header to set the mime type of the data that you are delivering:
Response.ContentType = "image/gif";
A bitmap saved to .NET stream is just a stream of bytes and does not hold a mime type by itself.
精彩评论