开发者

Bitmap.Save(Stream, ImageFormat) doesn't change MIME type

开发者 https://www.devze.com 2023-04-05 06:26 出处:网络
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

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消