public HttpResponseMessage Get(string imageName, int width, int height)
{
Image img = GetImage(imageName, width, height);
MemoryStream ms = new MemoryStream();
img.Save(ms, System.Drawing.Imaging.ImageFormat.Png);
HttpResponseMessage result = new HttpResponseMessage(HttpStatusCode.OK);
result.Content = new ByteArrayContent(ms.ToArray());
result.Content.Headers.ContentType = new MediaTypeHeaderValue("image/png");
return result;
}
MVC4 WebAPI中如何返回一张图片?
时间: 2024-11-05 20:54:16